nameserver replacement: scope only to selected domains

This commit is contained in:
Karl Erik Õunapuu 2020-11-06 15:51:03 +02:00
parent ed7181e060
commit 451e1f79af
No known key found for this signature in database
GPG key ID: C9DD647298A34764
4 changed files with 30 additions and 3 deletions

View file

@ -6,9 +6,13 @@ class Registrar
ipv4 = params[:ipv4].split("\r\n")
ipv6 = params[:ipv6].split("\r\n")
domains = domain_list_from_csv
puts "Domains are #{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,
attributes: { hostname: params[:new_hostname],
ipv4: ipv4,
ipv6: ipv6 } } }.to_json
@ -55,5 +59,13 @@ class Registrar
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
end
end
def domain_list_from_csv
return [] if params[:batch_file].blank?
domains = []
CSV.read(params[:batch_file].path, headers: true).each { |b| domains << b['domain_name'] }
domains
end
end
end