mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +02:00
Merge pull request #583 from internetee/refactor-settings
Refactor settings
This commit is contained in:
commit
80fa2a376c
16 changed files with 199 additions and 187 deletions
|
@ -50,9 +50,6 @@ strong
|
|||
blockquote
|
||||
margin: 1em 40px
|
||||
|
||||
dfn
|
||||
font-style: italic
|
||||
|
||||
mark
|
||||
background: #ff0
|
||||
color: #000
|
||||
|
@ -94,12 +91,6 @@ sup
|
|||
sub
|
||||
bottom: -0.25em
|
||||
|
||||
.title-row
|
||||
margin-bottom: 22px
|
||||
|
||||
.app-nav
|
||||
padding-top: 7px
|
||||
|
||||
.general-tab
|
||||
padding-top: 30px
|
||||
padding-right: 20px
|
||||
|
@ -131,16 +122,6 @@ sub
|
|||
font-weight: bold
|
||||
color: #333
|
||||
|
||||
|
||||
.subactions
|
||||
h4
|
||||
margin-bottom: 20px
|
||||
margin-top: 10px
|
||||
min-height: 600px
|
||||
|
||||
.sidebar
|
||||
min-height: 400px
|
||||
|
||||
.content
|
||||
margin-right: 240px
|
||||
margin-left: 0
|
||||
|
@ -148,15 +129,6 @@ sub
|
|||
h4
|
||||
margin: 0
|
||||
|
||||
.top-actions
|
||||
margin-top: 12px
|
||||
margin-bottom: 16px
|
||||
float: right
|
||||
|
||||
.domify
|
||||
td
|
||||
vertical-align: middle !important
|
||||
|
||||
body.login
|
||||
padding-top: 40px
|
||||
padding-bottom: 40px
|
||||
|
@ -196,12 +168,6 @@ body.login
|
|||
.form-control:focus
|
||||
z-index: 2
|
||||
|
||||
.error-tab > a
|
||||
color: #a94442 !important
|
||||
|
||||
.edit-highlight
|
||||
background-color: #E7E7E7
|
||||
|
||||
.navbar-brand
|
||||
line-height: 12px
|
||||
padding-top: 20px
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
body > .container
|
||||
min-height: 800px
|
||||
|
||||
.error-tab > a
|
||||
color: #a94442 !important
|
||||
|
||||
.edit-highlight
|
||||
background-color: #E7E7E7
|
||||
|
||||
.navbar-brand
|
||||
line-height: 12px
|
||||
padding-top: 20px
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module Admin
|
||||
class SettingsController < BaseController
|
||||
load_and_authorize_resource
|
||||
before_action :set_setting_group, only: [:show, :update]
|
||||
|
||||
def index
|
||||
@settings = Setting.unscoped
|
||||
|
@ -14,7 +13,7 @@ module Admin
|
|||
Setting[k] = v
|
||||
end
|
||||
|
||||
flash[:notice] = I18n.t('records_updated')
|
||||
flash[:notice] = t('.saved')
|
||||
redirect_to [:admin, :settings]
|
||||
else
|
||||
flash[:alert] = @errors.values.uniq.join(", ")
|
||||
|
@ -22,74 +21,16 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def show;
|
||||
end
|
||||
|
||||
def update
|
||||
if @setting_group.update(setting_group_params)
|
||||
flash[:notice] = I18n.t('setting_updated')
|
||||
redirect_to [:admin, @setting_group]
|
||||
else
|
||||
flash[:alert] = I18n.t('failed_to_update_setting')
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_setting_group
|
||||
@setting_group = SettingGroup.find(params[:id])
|
||||
end
|
||||
|
||||
def setting_group_params
|
||||
params.require(:setting_group).permit(settings_attributes: [:value, :id])
|
||||
end
|
||||
|
||||
def casted_settings # rubocop:disable Metrics/MethodLength
|
||||
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
|
||||
|
|
|
@ -20,4 +20,50 @@ class Setting < RailsSettings::CachedSettings
|
|||
|
||||
return errors
|
||||
end
|
||||
|
||||
def self.integer_settings
|
||||
%i[
|
||||
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
|
||||
]
|
||||
end
|
||||
|
||||
def self.float_settings
|
||||
%i[
|
||||
registry_vat_prc
|
||||
minimum_deposit
|
||||
]
|
||||
end
|
||||
|
||||
def self.boolean_settings
|
||||
%i[
|
||||
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
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
- if can?(:access, :settings_menu)
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
= t(:settings)
|
||||
= t('.settings')
|
||||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
%li.dropdown-header= t('.users')
|
||||
|
@ -30,7 +30,7 @@
|
|||
%li= link_to t('.contact_history'), admin_contact_versions_path
|
||||
%li.divider
|
||||
%li.dropdown-header= t(:system)
|
||||
%li= link_to t(:settings), admin_settings_path
|
||||
%li= link_to t('.settings'), admin_settings_path
|
||||
%li= link_to t('.zones'), admin_zones_path
|
||||
%li= link_to t('.blocked_domains'), admin_blocked_domains_path
|
||||
%li= link_to t('.reserved_domains'), admin_reserved_domains_path
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
- value = Setting.send(var)
|
||||
%tr{class: (@errors && @errors.has_key?(var.to_s) && "danger")}
|
||||
%td= t(var)
|
||||
%td.col-md-6= var.to_s.humanize
|
||||
- if [TrueClass, FalseClass].include?(value.class)
|
||||
%td
|
||||
= hidden_field_tag("[settings][#{var}]", '')
|
||||
%td.col-md-6
|
||||
= hidden_field_tag("[settings][#{var}]", '', id: nil)
|
||||
= check_box_tag("[settings][#{var}]", true, value)
|
||||
- else
|
||||
%td= text_field_tag("[settings][#{var}]", value)
|
||||
%td.col-md-6= text_field_tag("[settings][#{var}]", value, class: 'form-control')
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
= render 'shared/title', name: t(:settings)
|
||||
.page-header
|
||||
.h1
|
||||
= t('.title')
|
||||
|
||||
= form_tag [:admin, :settings] do
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:domain_validation_rules)
|
||||
.panel-heading
|
||||
= t('.domain_validation')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:setting)
|
||||
%th{class: 'col-xs-6'}= t(:value)
|
||||
%tbody
|
||||
= render 'setting_row', var: :admin_contacts_min_count
|
||||
= render 'setting_row', var: :admin_contacts_max_count
|
||||
|
@ -26,14 +24,10 @@
|
|||
= render 'setting_row', var: :expire_pending_confirmation
|
||||
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:domain_expiring)
|
||||
.panel-heading
|
||||
= t('.domain_expiration')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:setting)
|
||||
%th{class: 'col-xs-6'}= t(:value)
|
||||
%tbody
|
||||
= render 'setting_row', var: :days_to_renew_domain_before_expire
|
||||
= render 'setting_row', var: :expire_warning_period
|
||||
|
@ -41,14 +35,10 @@
|
|||
= render 'setting_row', var: :expiration_reminder_mail
|
||||
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:other)
|
||||
.panel-heading
|
||||
= t('.other')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:setting)
|
||||
%th{class: 'col-xs-6'}= t(:value)
|
||||
%tbody
|
||||
= render 'setting_row', var: :transfer_wait_time
|
||||
= render 'setting_row', var: :ds_digest_type
|
||||
|
@ -61,14 +51,10 @@
|
|||
= render 'setting_row', var: :address_processing
|
||||
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:billing_settings)
|
||||
.panel-heading
|
||||
= t('.billing')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:setting)
|
||||
%th{class: 'col-xs-6'}= t(:value)
|
||||
%tbody
|
||||
= render 'setting_row', var: :invoice_number_min
|
||||
= render 'setting_row', var: :invoice_number_max
|
||||
|
@ -91,14 +77,10 @@
|
|||
= render 'setting_row', var: :registry_swift
|
||||
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:registry_settings)
|
||||
.panel-heading
|
||||
= t('.contacts')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:setting)
|
||||
%th{class: 'col-xs-6'}= t(:value)
|
||||
%tbody
|
||||
= render 'setting_row', var: :registry_juridical_name
|
||||
= render 'setting_row', var: :registry_reg_no
|
||||
|
@ -113,4 +95,4 @@
|
|||
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
%button.btn.btn-primary=t(:save)
|
||||
= submit_tag(t('.save_btn'), class: 'btn btn-success', name: nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue