mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Prefixes to statuses are added now automatically in client
This commit is contained in:
parent
96eead47b7
commit
5083062de4
4 changed files with 23 additions and 2 deletions
|
@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
before_filter do
|
before_action do
|
||||||
resource = controller_name.singularize.to_sym
|
resource = controller_name.singularize.to_sym
|
||||||
method = "#{resource}_params"
|
method = "#{resource}_params"
|
||||||
params[resource] &&= send(method) if respond_to?(method, true)
|
params[resource] &&= send(method) if respond_to?(method, true)
|
||||||
|
|
|
@ -18,6 +18,8 @@ class Client::DomainsController < ClientController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
add_prefix_to_statuses
|
||||||
|
|
||||||
@domain = Domain.new(domain_params)
|
@domain = Domain.new(domain_params)
|
||||||
@domain.registrar = current_user.registrar
|
@domain.registrar = current_user.registrar
|
||||||
|
|
||||||
|
@ -36,6 +38,8 @@ class Client::DomainsController < ClientController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
add_prefix_to_statuses
|
||||||
|
|
||||||
if @domain.update(domain_params)
|
if @domain.update(domain_params)
|
||||||
flash[:notice] = I18n.t('shared.domain_updated')
|
flash[:notice] = I18n.t('shared.domain_updated')
|
||||||
redirect_to [:client, @domain]
|
redirect_to [:client, @domain]
|
||||||
|
@ -71,6 +75,12 @@ class Client::DomainsController < ClientController
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_prefix_to_statuses
|
||||||
|
domain_params[:domain_statuses_attributes].each do |_k, hash|
|
||||||
|
hash[:value] = hash[:value].prepend('client')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_domain
|
def set_domain
|
||||||
@domain = Domain.find(params[:id])
|
@domain = Domain.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,4 +40,15 @@ class DomainStatus < ActiveRecord::Base
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def statuses_for_client
|
||||||
|
ret = []
|
||||||
|
STATUSES.each do |x|
|
||||||
|
next unless x.start_with?('client')
|
||||||
|
ret << x.sub('client', '')
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group
|
.form-group
|
||||||
= status_fields.label :value
|
= status_fields.label :value
|
||||||
= status_fields.select :value, options_for_select(DomainStatus::STATUSES, status_fields.object.value), {include_blank: true}, {class: 'form-control'}
|
= status_fields.select :value, options_for_select(DomainStatus.statuses_for_client, status_fields.object.value.sub('client', '')), {include_blank: true}, {class: 'form-control'}
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group
|
.form-group
|
||||||
= status_fields.label :description
|
= status_fields.label :description
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue