Story#107192666 - validation for settings that DS data allowed and Allow key data cannot be both true

This commit is contained in:
Vladimir Krylov 2015-11-16 12:52:26 +02:00
parent fd4b2debb2
commit 035111e130
3 changed files with 26 additions and 6 deletions

View file

@ -6,4 +6,18 @@ class Setting < RailsSettings::CachedSettings
Rails.cache.delete_matched('settings:.*')
STDOUT << "#{Time.zone.now.utc} - Settings cache cleared\n"
end
# cannot do instance validation because CachedSetting use save!
def self.params_errors(params)
errors = {}
# DS data allowed and Allow key data cannot be both true
if !!params["key_data_allowed"] && params["key_data_allowed"] == params["ds_data_allowed"]
msg = "#{I18n.t(:key_data_allowed)} and #{I18n.t(:ds_data_with_key_allowed)} cannot be both true"
errors["key_data_allowed"] = msg
errors["ds_data_allowed"] = msg
end
return errors
end
end