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

@ -1,3 +1,11 @@
04.11.2020
* Email notification templates for forceDelete are now automatically selected according to registrant type [#442](https://github.com/internetee/registry/issues/442)
03.11.2020
* Fixed registrant confirmation while forcedelete is set on a domain [#1729](https://github.com/internetee/registry/issues/1729)
* Fixed search in registrar domain view [#262](https://github.com/internetee/registry/issues/262)
* Fixed double status issue on setting forceDelete [#1135](https://github.com/internetee/registry/issues/1135)
28.10.2020
* Domain renew now canceles pending delete process [#1664](https://github.com/internetee/registry/issues/1664)
* Added multi-language support to whois disclaimer [#1703](https://github.com/internetee/registry/issues/1703)

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]

View file

@ -19,6 +19,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
end
end
def notification_template
registrant.org? ? 'legal_person' : 'private_person'
end
def force_delete_scheduled?
statuses.include?(DomainStatus::FORCE_DELETE)
end
@ -129,9 +133,9 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
end
def add_force_delete_statuses
statuses << DomainStatus::FORCE_DELETE
statuses << DomainStatus::SERVER_RENEW_PROHIBITED
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
self.statuses |= [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED]
end
def remove_force_delete_statuses

View file

@ -384,7 +384,7 @@ class Domain < ApplicationRecord
end
def registrant_update_confirmable?(token)
return false if (statuses & [DomainStatus::FORCE_DELETE, DomainStatus::DELETE_CANDIDATE]).any?
return false if statuses.include? DomainStatus::DELETE_CANDIDATE
return false unless pending_update?
return false unless registrant_verification_asked?
return false unless registrant_verification_token == token

View file

@ -33,12 +33,6 @@
</div>
</div>
<div class="form-group email-template-row">
<label class="col-md-3 control-label"><%= t '.email_template' %></label>
<div class="col-md-9">
<%= select_tag 'template_name', options_for_select(templates), class: 'form-control' %>
</div>
</div>
<% end %>
<div class="modal-footer">

View file

@ -32,4 +32,4 @@
</div>
<%= render 'form' %>
<%= render 'force_delete_dialog', domain: @domain, templates: force_delete_templates %>
<%= render 'force_delete_dialog', domain: @domain %>

View file

@ -18,7 +18,8 @@
<div class="col-md-3">
<div class="form-group">
<%= f.label :contact_ident, for: nil %>
<%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
<%= f.search_field :contacts_ident_eq, value: search_params[:contacts_ident_eq],
class: 'form-control', placeholder: t(:contact_ident) %>
</div>
</div>

View file

@ -137,6 +137,19 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
assert_not @domain.force_delete_scheduled?
end
def test_force_delete_does_not_double_statuses
statuses = [
DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED,
]
@domain.statuses = @domain.statuses + statuses
@domain.save!
@domain.reload
@domain.schedule_force_delete(type: :fast_track)
assert_equal @domain.statuses.size, statuses.size
end
def test_cancelling_force_delete_removes_statuses_that_were_set_on_force_delete
statuses = [
DomainStatus::FORCE_DELETE,
@ -252,4 +265,16 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
assert @domain.force_delete_scheduled?
assert @domain.pending_update?
end
def test_force_delete_does_not_affect_registrant_update_confirmable
@domain.schedule_force_delete(type: :soft)
@domain.registrant_verification_asked!('test', User.last.id)
@domain.save!
@domain.reload
@domain.statuses << DomainStatus::PENDING_UPDATE
assert @domain.force_delete_scheduled?
assert @domain.registrant_update_confirmable?(@domain.registrant_verification_token)
end
end

View file

@ -42,6 +42,22 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
find(:css, '#soft_delete').set(true)
click_link_or_button 'Force delete domain'
end
@domain.reload
assert_equal template_name, @domain.template_name
end
def test_uses_legal_template_if_registrant_org
@domain.registrant.update(ident_type: 'org')
assert_emails 0 do
visit edit_admin_domain_url(@domain)
find(:css, '#soft_delete').set(true)
click_link_or_button 'Force delete domain'
end
@domain.reload
assert_equal template_name, @domain.template_name
end
def test_allows_to_skip_notifying_registrant_and_admin_contacts_by_email
@ -71,4 +87,10 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
assert_no_button 'Schedule force delete'
assert_no_link 'Schedule force delete'
end
private
def template_name
@domain.registrant.org? ? 'legal_person' : 'private_person'
end
end