mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 20:27:30 +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)
|
||||
|
||||
if response.code == '200'
|
||||
notices = [t('.replaced')]
|
||||
notices << "#{t('.affected_domains')}: " \
|
||||
"#{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
|
||||
redirect_to(registrar_domains_url,
|
||||
flash: { notice: compose_notice_message(parsed_response) })
|
||||
else
|
||||
@api_errors = parsed_response[:message]
|
||||
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
|
||||
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
|
||||
return [] if params[:puny_file].blank?
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ module Repp
|
|||
|
||||
def update
|
||||
affected, errored = current_user.registrar
|
||||
.replace_nameservers(hostname,
|
||||
hostname_params[:data][:attributes],
|
||||
domains: domains_from_params)
|
||||
.replace_nameservers(hostname,
|
||||
hostname_params[:data][:attributes],
|
||||
domains: domains_from_params)
|
||||
|
||||
render_success(data: data_format_for_success(affected, errored))
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
|
|
|
@ -144,6 +144,7 @@ class Registrar < ApplicationRecord
|
|||
# Audit log is needed, therefore no raw SQL
|
||||
def replace_nameservers(hostname, new_attributes, domains: [])
|
||||
transaction do
|
||||
domain_scope = domains.dup
|
||||
domain_list = []
|
||||
failed_list = []
|
||||
|
||||
|
@ -162,13 +163,14 @@ class Registrar < ApplicationRecord
|
|||
new_nameserver.attributes = new_attributes
|
||||
new_nameserver.save!
|
||||
|
||||
domain_scope.delete_if { |i| i == idn || i == puny }
|
||||
domain_list << idn
|
||||
|
||||
origin.destroy!
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ en:
|
|||
update:
|
||||
replaced: Nameserver have been successfully replaced
|
||||
affected_domains: Affected domains
|
||||
skipped_domains: Skipped domains
|
||||
skipped_domains: Untouched domains
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue