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
|
if !setting
|
||||||
fail "Can't find config setting '#{name}'"
|
fail "Can't find config setting '#{name}'"
|
||||||
end
|
end
|
||||||
if setting.respond_to?(:state_current)
|
setting.state_current = { value: value }
|
||||||
setting.state_current = { value: value }
|
|
||||||
else
|
|
||||||
setting.state = { value: value }
|
|
||||||
end
|
|
||||||
setting.save
|
setting.save
|
||||||
logger.info "Setting.set(#{name}, #{value.inspect})"
|
logger.info "Setting.set(#{name}, #{value.inspect})"
|
||||||
end
|
end
|
||||||
|
@ -70,15 +66,9 @@ reset config setting to default
|
||||||
if !setting
|
if !setting
|
||||||
fail "Can't find config setting '#{name}'"
|
fail "Can't find config setting '#{name}'"
|
||||||
end
|
end
|
||||||
if setting.respond_to?(:state_current)
|
setting.state_current = setting.state_initial
|
||||||
setting.state_current = setting.state_initial
|
setting.save
|
||||||
setting.save
|
logger.info "Setting.reset(#{name}, #{setting.state_current.inspect})"
|
||||||
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
|
|
||||||
load
|
load
|
||||||
@@current[:settings_config][name]
|
@@current[:settings_config][name]
|
||||||
end
|
end
|
||||||
|
@ -95,16 +85,9 @@ reset config setting to default
|
||||||
|
|
||||||
# read all config settings
|
# read all config settings
|
||||||
config = {}
|
config = {}
|
||||||
s = Setting.new
|
Setting.select('name, state_current').order(:id).each { |setting|
|
||||||
if s.respond_to?(:state_current)
|
config[setting.name] = setting.state_current[:value]
|
||||||
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
|
|
||||||
|
|
||||||
# config lookups
|
# config lookups
|
||||||
config.each { |key, value|
|
config.each { |key, value|
|
||||||
|
@ -122,11 +105,7 @@ reset config setting to default
|
||||||
|
|
||||||
# set initial value in state_initial
|
# set initial value in state_initial
|
||||||
def set_initial
|
def set_initial
|
||||||
if self.respond_to?(:state_current)
|
self.state_initial = state_current
|
||||||
self.state_initial = state_current
|
|
||||||
else
|
|
||||||
self.state_initial = state
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# set new cache
|
# set new cache
|
||||||
|
@ -165,10 +144,6 @@ reset config setting to default
|
||||||
# convert state ot hash to be able to store it as store
|
# convert state ot hash to be able to store it as store
|
||||||
def state_check
|
def state_check
|
||||||
return if state && state.respond_to?('has_key?') && state.key?(:value)
|
return if state && state.respond_to?('has_key?') && state.key?(:value)
|
||||||
if self.respond_to?(:state_current)
|
self.state_current = { value: state }
|
||||||
self.state_current = { value: state }
|
|
||||||
else
|
|
||||||
self.state = { value: state }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# sync logo to fs / only if settings already exists
|
# sync logo to fs / only if settings already exists
|
||||||
if ActiveRecord::Base.connection.tables.include?('settings')
|
if ActiveRecord::Base.connection.tables.include?('settings')
|
||||||
StaticAssets.sync
|
if Setting.column_names.include?('state_current')
|
||||||
|
StaticAssets.sync
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -210,7 +210,7 @@ class CreateBase < ActiveRecord::Migration
|
||||||
t.string :client_id, null: false
|
t.string :client_id, null: false
|
||||||
t.string :key, limit: 100, null: false
|
t.string :key, limit: 100, null: false
|
||||||
t.string :callback, 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.string :params, limit: 2000, null: true
|
||||||
t.integer :prio, null: false
|
t.integer :prio, null: false
|
||||||
t.boolean :notify, null: false, default: 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 :area, limit: 100, null: false
|
||||||
t.string :description, limit: 2000, null: false
|
t.string :description, limit: 2000, null: false
|
||||||
t.string :options, limit: 2000, null: true
|
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.string :state_initial, limit: 2000, null: true
|
||||||
t.boolean :frontend, null: false
|
t.boolean :frontend, null: false
|
||||||
t.timestamps
|
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