mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 22:12:02 +08:00
ba6d4b2a8d
If you turn it on now, default all users to approved since they were previously. Also support approving a user that doesn't have a reviewable record (it will be created first.) This also includes a refactor to move class method calls to `DiscourseEvent` into an initializer. Otherwise the load order of classes makes a difference in the test environment and some settings might be triggered and others not, randomly.
63 lines
1.0 KiB
Ruby
63 lines
1.0 KiB
Ruby
module SiteSettings; end
|
|
|
|
class SiteSettings::LocalProcessProvider
|
|
|
|
attr_accessor :current_site
|
|
|
|
class Setting
|
|
attr_accessor :name, :data_type, :value
|
|
|
|
def value_changed?
|
|
true
|
|
end
|
|
|
|
def saved_change_to_value?
|
|
true
|
|
end
|
|
|
|
def initialize(name, data_type)
|
|
self.name = name
|
|
self.data_type = data_type
|
|
end
|
|
end
|
|
|
|
def settings
|
|
@settings[current_site] ||= {}
|
|
end
|
|
|
|
def initialize
|
|
@settings = {}
|
|
self.current_site = "test"
|
|
end
|
|
|
|
def all
|
|
settings.values
|
|
end
|
|
|
|
def find(name)
|
|
settings[name]
|
|
end
|
|
|
|
def save(name, value, data_type)
|
|
# NOTE: convert to string to simulate the conversion that is happening
|
|
# when using DbProvider
|
|
setting = settings[name]
|
|
if setting.blank?
|
|
setting = Setting.new(name, data_type)
|
|
settings[name] = setting
|
|
end
|
|
setting.value = value.to_s
|
|
DiscourseEvent.trigger(:site_setting_saved, setting)
|
|
setting
|
|
end
|
|
|
|
def destroy(name)
|
|
settings.delete(name)
|
|
end
|
|
|
|
def clear
|
|
@settings[current_site] = {}
|
|
end
|
|
|
|
end
|