Merge remote-tracking branch 'origin/master' into 1177-bulk-force-delete

This commit is contained in:
Karl Erik Õunapuu 2020-11-04 16:39:04 +02:00
commit 1217ed633f
No known key found for this signature in database
GPG key ID: C9DD647298A34764
10 changed files with 84 additions and 25 deletions

View file

@ -22,7 +22,7 @@ module Admin
send_email
domain.update(contact_notification_sent_date: Time.zone.today)
else
domain.update(template_name: params[:template_name])
domain.update(template_name: domain.notification_template)
end
end
@ -46,7 +46,7 @@ module Admin
DomainDeleteMailer.forced(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant,
template_name: params[:template_name]).deliver_now
template_name: domain.notification_template).deliver_now
end
def force_delete_type

View file

@ -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]