mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
Merge remote-tracking branch 'origin/master' into 1580-registrar-api-contacts-endpoint
This commit is contained in:
commit
db50a89d85
51 changed files with 801 additions and 285 deletions
|
@ -11,26 +11,27 @@ class Registrar
|
|||
search_params[:name_matches].present?
|
||||
domain = Domain.find_by(name: search_params[:name_matches])
|
||||
|
||||
if domain
|
||||
redirect_to info_registrar_domains_url(domain_name: domain.name) and return
|
||||
end
|
||||
redirect_to info_registrar_domains_url(domain_name: domain.name) and return if domain
|
||||
end
|
||||
|
||||
if params[:statuses_contains]
|
||||
domains = current_registrar_user.registrar.domains.includes(:registrar, :registrant).where(
|
||||
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
||||
)
|
||||
else
|
||||
domains = current_registrar_user.registrar.domains.includes(:registrar, :registrant)
|
||||
domains = if params[:statuses_contains]
|
||||
current_domain_scope.where('domains.statuses @> ?::varchar[]',
|
||||
"{#{params[:statuses_contains].join(',')}}")
|
||||
else
|
||||
current_domain_scope
|
||||
end
|
||||
|
||||
if params[:contacts_ident_eq]
|
||||
domains = domains.where(contacts: { ident: params[:contacts_ident_eq] })
|
||||
end
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(search_params)
|
||||
@q = domains.search(search_params.except(:contacts_ident_eq))
|
||||
@domains = @q.result.page(params[:page])
|
||||
|
||||
# if we do not get any results, add wildcards to the name field and search again
|
||||
if @domains.count == 0 && search_params[:name_matches] !~ /^%.+%$/
|
||||
new_search_params = search_params.to_h
|
||||
new_search_params = search_params.to_h.except(:contacts_ident_eq)
|
||||
new_search_params[:name_matches] = "%#{new_search_params[:name_matches]}%"
|
||||
@q = domains.search(new_search_params)
|
||||
@domains = @q.result.page(params[:page])
|
||||
|
@ -56,6 +57,10 @@ class Registrar
|
|||
end
|
||||
end
|
||||
|
||||
def current_domain_scope
|
||||
current_registrar_user.registrar.domains.includes(:registrar, :registrant)
|
||||
end
|
||||
|
||||
def info
|
||||
authorize! :info, Depp::Domain
|
||||
@data = @domain.info(params[:domain_name]) if params[:domain_name]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue