mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 06:48:18 +08:00
FIX: Better handling for toggling must_approve_users
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.
This commit is contained in:
@ -4,7 +4,22 @@ class SiteSettings::LocalProcessProvider
|
||||
|
||||
attr_accessor :current_site
|
||||
|
||||
Setting = Struct.new(:name, :value, :data_type) unless defined? SiteSettings::LocalProcessProvider::Setting
|
||||
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] ||= {}
|
||||
@ -26,8 +41,14 @@ class SiteSettings::LocalProcessProvider
|
||||
def save(name, value, data_type)
|
||||
# NOTE: convert to string to simulate the conversion that is happening
|
||||
# when using DbProvider
|
||||
value = value.to_s
|
||||
settings[name] = Setting.new(name, value, data_type)
|
||||
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)
|
||||
|
Reference in New Issue
Block a user