mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Nameserver hostname replacing
This commit is contained in:
parent
23098add74
commit
1f2ba55acb
7 changed files with 135 additions and 0 deletions
38
app/controllers/registrar/nameservers_controller.rb
Normal file
38
app/controllers/registrar/nameservers_controller.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
class Registrar::NameserversController < RegistrarController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
nameservers = current_user.registrar.nameservers
|
||||
@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
|
||||
|
||||
def can_replace_hostnames?
|
||||
if params[:replace] && params[:q]
|
||||
flash.now[:alert] = t('hostname_end_replacement_is_required') unless params[:hostname_end_replacement].present?
|
||||
flash.now[:alert] = t('hostname_end_is_required') unless params[:q][:hostname_end].present?
|
||||
return true if flash[:alert].blank?
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue