Merge pull request #1738 from internetee/1737-domain-scoped-ns-replacement

Nameserver replacement: scope to selected domains
This commit is contained in:
Timo Võhmar 2020-11-06 17:09:36 +02:00 committed by GitHub
commit d00aab62bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 3 deletions

View file

@ -6,9 +6,12 @@ class Registrar
ipv4 = params[:ipv4].split("\r\n")
ipv6 = params[:ipv6].split("\r\n")
domains = domain_list_from_csv
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 +58,13 @@ class Registrar
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
end
end
def domain_list_from_csv
return [] if params[:puny_file].blank?
domains = []
CSV.read(params[:puny_file].path, headers: true).each { |b| domains << b['domain_name'] }
domains
end
end
end