mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Bulk NS change: Verify CSV integrity
This commit is contained in:
parent
067db7aa0a
commit
4170554ca1
1 changed files with 13 additions and 4 deletions
|
@ -7,11 +7,12 @@ class Registrar
|
|||
ipv6 = params[:ipv6].split("\r\n")
|
||||
|
||||
domains = domain_list_from_csv
|
||||
return csv_list_empty_guard if domains == []
|
||||
|
||||
uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
|
||||
request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
|
||||
request.body = { data: { type: 'nameserver', id: params[:old_hostname],
|
||||
domains: domains,
|
||||
domains: domains || [],
|
||||
attributes: { hostname: params[:new_hostname],
|
||||
ipv4: ipv4,
|
||||
ipv6: ipv6 } } }.to_json
|
||||
|
@ -42,12 +43,20 @@ class Registrar
|
|||
notices.join(', ')
|
||||
end
|
||||
|
||||
def csv_list_empty_guard
|
||||
notice = 'CSV scoped domain list seems empty. Make sure that domains are added and ' \
|
||||
'"domain_name" header is present.'
|
||||
redirect_to(registrar_domains_url, flash: { notice: notice })
|
||||
end
|
||||
|
||||
def domain_list_from_csv
|
||||
return [] if params[:puny_file].blank?
|
||||
return if params[:puny_file].blank?
|
||||
|
||||
domains = []
|
||||
CSV.read(params[:puny_file].path, headers: true).each { |b| domains << b['domain_name'] }
|
||||
domains
|
||||
CSV.read(params[:puny_file].path, headers: true).map { |b| domains << b['domain_name'] }
|
||||
domains.compact
|
||||
rescue CSV::MalformedCSVError
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue