mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 07:02:04 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
c6a93a3acd
8 changed files with 67 additions and 12 deletions
|
@ -15,6 +15,8 @@ class Admin::DomainsController < AdminController
|
|||
end
|
||||
|
||||
def update
|
||||
add_prefix_to_statuses
|
||||
|
||||
if @domain.update(domain_params)
|
||||
flash[:notice] = I18n.t('shared.domain_updated')
|
||||
redirect_to [:admin, @domain]
|
||||
|
@ -36,4 +38,10 @@ class Admin::DomainsController < AdminController
|
|||
domain_statuses_attributes: [:id, :value, :description, :_destroy]
|
||||
)
|
||||
end
|
||||
|
||||
def add_prefix_to_statuses
|
||||
domain_params[:domain_statuses_attributes].each do |_k, hash|
|
||||
hash[:value] = hash[:value].prepend('server')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,12 @@ class ApplicationController < ActionController::Base
|
|||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
before_action do
|
||||
resource = controller_name.singularize.to_sym
|
||||
method = "#{resource}_params"
|
||||
params[resource] &&= send(method) if respond_to?(method, true)
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
if resource.admin?
|
||||
(session[:user_return_to].nil?) ? admin_root_path : session[:user_return_to].to_s
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Client::DomainsController < ClientController
|
||||
load_and_authorize_resource
|
||||
before_action :set_domain, only: [:show, :edit, :update, :destroy]
|
||||
before_action :verify_deletion, only: [:destroy]
|
||||
load_and_authorize_resource
|
||||
before_action :set_domain, only: [:show, :edit, :update, :destroy]
|
||||
before_action :verify_deletion, only: [:destroy]
|
||||
|
||||
def index
|
||||
@q = Domain.search(params[:q]) if current_user.admin?
|
||||
|
@ -18,6 +18,8 @@ class Client::DomainsController < ClientController
|
|||
end
|
||||
|
||||
def create
|
||||
add_prefix_to_statuses
|
||||
|
||||
@domain = Domain.new(domain_params)
|
||||
@domain.registrar = current_user.registrar
|
||||
|
||||
|
@ -36,6 +38,8 @@ class Client::DomainsController < ClientController
|
|||
end
|
||||
|
||||
def update
|
||||
add_prefix_to_statuses
|
||||
|
||||
if @domain.update(domain_params)
|
||||
flash[:notice] = I18n.t('shared.domain_updated')
|
||||
redirect_to [:client, @domain]
|
||||
|
@ -46,6 +50,16 @@ class Client::DomainsController < ClientController
|
|||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @domain.destroy
|
||||
flash[:notice] = I18n.t('shared.domain_deleted')
|
||||
redirect_to client_domains_path
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_delete_domain')
|
||||
redirect_to [:client, @domain]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain_params
|
||||
|
@ -61,6 +75,12 @@ class Client::DomainsController < ClientController
|
|||
)
|
||||
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
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
@ -74,6 +94,6 @@ class Client::DomainsController < ClientController
|
|||
def verify_deletion
|
||||
return if @domain.can_be_deleted?
|
||||
flash[:alert] = I18n.t('shared.domain_status_prohibits_deleting')
|
||||
redirect_to [:admin, @domain]
|
||||
redirect_to [:client, @domain]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue