Fixed change of value / value_current.
This commit is contained in:
parent
918cbd178a
commit
4946c40679
4 changed files with 21 additions and 37 deletions
|
@ -31,11 +31,7 @@ set config setting
|
|||
if !setting
|
||||
fail "Can't find config setting '#{name}'"
|
||||
end
|
||||
if setting.respond_to?(:state_current)
|
||||
setting.state_current = { value: value }
|
||||
else
|
||||
setting.state = { value: value }
|
||||
end
|
||||
setting.state_current = { value: value }
|
||||
setting.save
|
||||
logger.info "Setting.set(#{name}, #{value.inspect})"
|
||||
end
|
||||
|
@ -70,15 +66,9 @@ reset config setting to default
|
|||
if !setting
|
||||
fail "Can't find config setting '#{name}'"
|
||||
end
|
||||
if setting.respond_to?(:state_current)
|
||||
setting.state_current = setting.state_initial
|
||||
setting.save
|
||||
logger.info "Setting.reset(#{name}, #{setting.state_current.inspect})"
|
||||
else
|
||||
setting.state = setting.state_initial
|
||||
setting.save
|
||||
logger.info "Setting.reset(#{name}, #{setting.state_current.inspect})"
|
||||
end
|
||||
setting.state_current = setting.state_initial
|
||||
setting.save
|
||||
logger.info "Setting.reset(#{name}, #{setting.state_current.inspect})"
|
||||
load
|
||||
@@current[:settings_config][name]
|
||||
end
|
||||
|
@ -95,16 +85,9 @@ reset config setting to default
|
|||
|
||||
# read all config settings
|
||||
config = {}
|
||||
s = Setting.new
|
||||
if s.respond_to?(:state_current)
|
||||
Setting.select('name, state_current').order(:id).each { |setting|
|
||||
config[setting.name] = setting.state_current[:value]
|
||||
}
|
||||
else
|
||||
Setting.select('name, state').order(:id).each { |setting|
|
||||
config[setting.name] = setting.state[:value]
|
||||
}
|
||||
end
|
||||
Setting.select('name, state_current').order(:id).each { |setting|
|
||||
config[setting.name] = setting.state_current[:value]
|
||||
}
|
||||
|
||||
# config lookups
|
||||
config.each { |key, value|
|
||||
|
@ -122,11 +105,7 @@ reset config setting to default
|
|||
|
||||
# set initial value in state_initial
|
||||
def set_initial
|
||||
if self.respond_to?(:state_current)
|
||||
self.state_initial = state_current
|
||||
else
|
||||
self.state_initial = state
|
||||
end
|
||||
self.state_initial = state_current
|
||||
end
|
||||
|
||||
# set new cache
|
||||
|
@ -165,10 +144,6 @@ reset config setting to default
|
|||
# convert state ot hash to be able to store it as store
|
||||
def state_check
|
||||
return if state && state.respond_to?('has_key?') && state.key?(:value)
|
||||
if self.respond_to?(:state_current)
|
||||
self.state_current = { value: state }
|
||||
else
|
||||
self.state = { value: state }
|
||||
end
|
||||
self.state_current = { value: state }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# sync logo to fs / only if settings already exists
|
||||
if ActiveRecord::Base.connection.tables.include?('settings')
|
||||
StaticAssets.sync
|
||||
if Setting.column_names.include?('state_current')
|
||||
StaticAssets.sync
|
||||
end
|
||||
end
|
||||
|
|
|
@ -210,7 +210,7 @@ class CreateBase < ActiveRecord::Migration
|
|||
t.string :client_id, null: false
|
||||
t.string :key, limit: 100, null: false
|
||||
t.string :callback, limit: 100, null: false
|
||||
t.string :state, limit: 8000, null: true
|
||||
t.column :state, :text, limit: 2.megabytes + 1, null: true
|
||||
t.string :params, limit: 2000, null: true
|
||||
t.integer :prio, null: false
|
||||
t.boolean :notify, null: false, default: false
|
||||
|
@ -320,7 +320,7 @@ class CreateBase < ActiveRecord::Migration
|
|||
t.string :area, limit: 100, null: false
|
||||
t.string :description, limit: 2000, null: false
|
||||
t.string :options, limit: 2000, null: true
|
||||
t.string :state, limit: 2000, null: true
|
||||
t.string :state_current, limit: 2000, null: true
|
||||
t.string :state_initial, limit: 2000, null: true
|
||||
t.boolean :frontend, null: false
|
||||
t.timestamps
|
||||
|
|
7
db/migrate/20150978000001_update_settings6.rb
Normal file
7
db/migrate/20150978000001_update_settings6.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class UpdateSettings6 < ActiveRecord::Migration
|
||||
def up
|
||||
if Setting.column_names.include?('state')
|
||||
rename_column :settings, :state, :state_current
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue