internetee-registry/app/controllers/admin/settings_controller.rb
Alex Sherman 56c7eb5f26 Remove some keys from legacy copy/show
Setting with key 'days_to_keep_business_registry_cache' is not copied/shown now.
Setting with key 'default_language' is copied, but shown only once now.
2020-08-26 13:31:26 +05:00

38 lines
1 KiB
Ruby

module Admin
class SettingsController < BaseController
load_and_authorize_resource
def index
@settings = SettingEntry.unscoped
@validation_settings = SettingEntry.with_group('domain_validation')
@expiration_settings = SettingEntry.with_group('domain_expiration')
@other_settings = SettingEntry.with_group('other')
.where.not(code: 'default_language')
@billing_settings = SettingEntry.with_group('billing')
@contacts_settings = SettingEntry.with_group('contacts')
end
def create
update = SettingEntry.update(casted_settings.keys, casted_settings.values)
if update
flash[:notice] = t('.saved')
redirect_to %i[admin settings]
else
flash[:alert] = update.errors.values.uniq.join(', ')
render 'admin/settings/index'
end
end
private
def casted_settings
settings = {}
params[:settings].each do |k, v|
settings[k] = { value: v }
end
settings
end
end
end