Move setting types from controller to model

This commit is contained in:
Artur Beljajev 2017-08-23 01:24:01 +03:00
parent 6d7701e52f
commit b632dbc2de
4 changed files with 141 additions and 47 deletions

View file

@ -26,48 +26,11 @@ module Admin
def casted_settings
settings = {}
ints = [
:admin_contacts_min_count,
:admin_contacts_max_count,
:tech_contacts_min_count,
:tech_contacts_max_count,
:orphans_contacts_in_months,
:ds_digest_type,
:dnskeys_min_count,
:dnskeys_max_count,
:ns_min_count,
:ns_max_count,
:transfer_wait_time,
:invoice_number_min,
:invoice_number_max,
:days_to_keep_business_registry_cache,
:days_to_keep_invoices_active,
:days_to_keep_overdue_invoices_active,
:days_to_renew_domain_before_expire,
:expire_warning_period,
:redemption_grace_period,
:expire_pending_confirmation
]
floats = [:registry_vat_prc, :minimum_deposit]
booleans = [
:ds_data_allowed,
:key_data_allowed,
:client_side_status_editing_enabled,
:registrar_ip_whitelist_enabled,
:api_ip_whitelist_enabled,
:request_confrimation_on_registrant_change_enabled,
:request_confirmation_on_domain_deletion_enabled,
:nameserver_required,
:address_processing
]
params[:settings].each do |k, v|
settings[k] = v
settings[k] = v.to_i if ints.include?(k.to_sym)
settings[k] = v.to_f if floats.include?(k.to_sym)
settings[k] = (v == 'true' ? true : false) if booleans.include?(k.to_sym)
settings[k] = v.to_i if Setting.integer_settings.include?(k.to_sym)
settings[k] = v.to_f if Setting.float_settings.include?(k.to_sym)
settings[k] = (v == 'true' ? true : false) if Setting.boolean_settings.include?(k.to_sym)
end
settings