mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
Merge pull request #1749 from internetee/1739-ns-bulk-change-test-and-whois-update
Registrar: Update WHOIS after bulk nameserver change
This commit is contained in:
commit
18790071c9
8 changed files with 102 additions and 23 deletions
|
@ -48,18 +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(', ')}"
|
||||
|
||||
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?
|
||||
|
||||
|
|
|
@ -5,25 +5,31 @@ module Repp
|
|||
before_action :verify_nameserver_existance, only: %i[update]
|
||||
|
||||
def update
|
||||
domains = params[:data][:domains] || []
|
||||
affected = current_user.registrar
|
||||
.replace_nameservers(hostname,
|
||||
hostname_params[:data][:attributes],
|
||||
domains: domains)
|
||||
affected, errored = current_user.registrar
|
||||
.replace_nameservers(hostname,
|
||||
hostname_params[:data][:attributes],
|
||||
domains: domains_from_params)
|
||||
|
||||
render_success(data: data_format_for_success(affected))
|
||||
render_success(data: data_format_for_success(affected, errored))
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
handle_errors(e.record)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def data_format_for_success(affected_domains)
|
||||
def domains_from_params
|
||||
return [] unless params[:data][:domains]
|
||||
|
||||
params[:data][:domains].map(&:downcase)
|
||||
end
|
||||
|
||||
def data_format_for_success(affected_domains, errored_domains)
|
||||
{
|
||||
type: 'nameserver',
|
||||
id: params[:data][:attributes][:hostname],
|
||||
attributes: params[:data][:attributes],
|
||||
affected_domains: affected_domains,
|
||||
skipped_domains: errored_domains,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue