mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Bulk NS change: track untouched domains
This commit is contained in:
parent
8bb0fd80d1
commit
af0a0611ce
4 changed files with 20 additions and 15 deletions
|
@ -48,22 +48,25 @@ class Registrar
|
||||||
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
if response.code == '200'
|
if response.code == '200'
|
||||||
notices = [t('.replaced')]
|
redirect_to(registrar_domains_url,
|
||||||
notices << "#{t('.affected_domains')}: " \
|
flash: { notice: compose_notice_message(parsed_response) })
|
||||||
"#{parsed_response[:data][:affected_domains].join(', ')}"
|
|
||||||
if parsed_response[:data][:skipped_domains]
|
|
||||||
notices << "#{t('.skipped_domains')}: " \
|
|
||||||
"#{parsed_response[:data][:skipped_domains].join(', ')}"
|
|
||||||
end
|
|
||||||
|
|
||||||
flash[:notice] = notices.join(', ')
|
|
||||||
redirect_to registrar_domains_url
|
|
||||||
else
|
else
|
||||||
@api_errors = parsed_response[:message]
|
@api_errors = parsed_response[:message]
|
||||||
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
|
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def compose_notice_message(res)
|
||||||
|
notices = ["#{t('.replaced')}. #{t('.affected_domains')}: " \
|
||||||
|
"#{res[:data][:affected_domains].join(', ')}"]
|
||||||
|
|
||||||
|
if res[:data][:skipped_domains]
|
||||||
|
notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}"
|
||||||
|
end
|
||||||
|
|
||||||
|
notices.join(', ')
|
||||||
|
end
|
||||||
|
|
||||||
def domain_list_from_csv
|
def domain_list_from_csv
|
||||||
return [] if params[:puny_file].blank?
|
return [] if params[:puny_file].blank?
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ module Repp
|
||||||
|
|
||||||
def update
|
def update
|
||||||
affected, errored = current_user.registrar
|
affected, errored = current_user.registrar
|
||||||
.replace_nameservers(hostname,
|
.replace_nameservers(hostname,
|
||||||
hostname_params[:data][:attributes],
|
hostname_params[:data][:attributes],
|
||||||
domains: domains_from_params)
|
domains: domains_from_params)
|
||||||
|
|
||||||
render_success(data: data_format_for_success(affected, errored))
|
render_success(data: data_format_for_success(affected, errored))
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
|
|
@ -144,6 +144,7 @@ class Registrar < ApplicationRecord
|
||||||
# Audit log is needed, therefore no raw SQL
|
# Audit log is needed, therefore no raw SQL
|
||||||
def replace_nameservers(hostname, new_attributes, domains: [])
|
def replace_nameservers(hostname, new_attributes, domains: [])
|
||||||
transaction do
|
transaction do
|
||||||
|
domain_scope = domains.dup
|
||||||
domain_list = []
|
domain_list = []
|
||||||
failed_list = []
|
failed_list = []
|
||||||
|
|
||||||
|
@ -162,13 +163,14 @@ class Registrar < ApplicationRecord
|
||||||
new_nameserver.attributes = new_attributes
|
new_nameserver.attributes = new_attributes
|
||||||
new_nameserver.save!
|
new_nameserver.save!
|
||||||
|
|
||||||
|
domain_scope.delete_if { |i| i == idn || i == puny }
|
||||||
domain_list << idn
|
domain_list << idn
|
||||||
|
|
||||||
origin.destroy!
|
origin.destroy!
|
||||||
end
|
end
|
||||||
|
|
||||||
self.domains.where(name: domain_list).find_each(&:update_whois_record) if domain_list.any?
|
self.domains.where(name: domain_list).find_each(&:update_whois_record) if domain_list.any?
|
||||||
[domain_list.uniq.sort, failed_list.uniq.sort]
|
[domain_list.uniq.sort, (domain_scope + failed_list).uniq.sort]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,4 @@ en:
|
||||||
update:
|
update:
|
||||||
replaced: Nameserver have been successfully replaced
|
replaced: Nameserver have been successfully replaced
|
||||||
affected_domains: Affected domains
|
affected_domains: Affected domains
|
||||||
skipped_domains: Skipped domains
|
skipped_domains: Untouched domains
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue