mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
Refactor and view improvement
This commit is contained in:
parent
1f2ba55acb
commit
03a66e2e68
5 changed files with 47 additions and 34 deletions
|
@ -2,27 +2,29 @@ class Registrar::NameserversController < RegistrarController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
nameservers = current_user.registrar.nameservers
|
||||
if can_replace_hostnames?
|
||||
res = Nameserver.replace_hostname_ends(
|
||||
current_user.registrar.domains.includes(
|
||||
:registrant, :nameservers, :admin_domain_contacts, :tech_domain_contacts, :domain_statuses,
|
||||
:versions, :admin_contacts, :tech_contacts, :whois_record, :dnskeys
|
||||
),
|
||||
params[:q][:hostname_end],
|
||||
params[:hostname_end_replacement]
|
||||
)
|
||||
|
||||
if res
|
||||
params[:q][:hostname_end] = params[:hostname_end_replacement]
|
||||
params[:hostname_end_replacement] = nil
|
||||
flash.now[:notice] = t('all_hostnames_replaced')
|
||||
else
|
||||
flash.now[:warning] = t('hostnames_partially_replaced')
|
||||
end
|
||||
end
|
||||
|
||||
nameservers = current_user.registrar.nameservers.includes(:domain)
|
||||
@q = nameservers.search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@nameservers = @q.result.page(params[:page])
|
||||
|
||||
return unless can_replace_hostnames?
|
||||
|
||||
res = Nameserver.replace_hostname_ends(
|
||||
current_user.registrar.domains.includes(
|
||||
:registrant, :nameservers, :admin_domain_contacts, :tech_domain_contacts, :domain_statuses,
|
||||
:versions, :admin_contacts, :tech_contacts, :whois_record, :dnskeys
|
||||
),
|
||||
params[:q][:hostname_end],
|
||||
params[:hostname_end_replacement]
|
||||
)
|
||||
|
||||
if res
|
||||
flash.now[:notice] = t('all_hostnames_replaced')
|
||||
else
|
||||
flash.now[:warning] = t('hostnames_partially_replaced')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue