mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 08:54:47 +08:00
Some site settings support backfilling if the user specified it. This works fine for singular site settings sent to the SiteSettingsController#update endpoint, but with bulk save we need to support this for a list of settings as well. This change alters the params format for SiteSetting::Update. It also moves the backfill logic into the service.
24 lines
604 B
Ruby
24 lines
604 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SiteSetting::Policy::SettingsAreVisible < Service::PolicyBase
|
|
delegate :options, :params, to: :context
|
|
|
|
def call
|
|
@hidden_settings = params.settings.map(&:name).select(&method(:validate_setting))
|
|
@hidden_settings.empty?
|
|
end
|
|
|
|
def reason
|
|
I18n.t(
|
|
"errors.site_settings.site_settings_are_hidden",
|
|
setting_names: @hidden_settings.join(", "),
|
|
)
|
|
end
|
|
|
|
private
|
|
|
|
def validate_setting(setting_name)
|
|
return false if options.allow_changing_hidden.include?(setting_name)
|
|
SiteSetting.hidden_settings.include?(setting_name)
|
|
end
|
|
end
|