Merge pull request #1483 from internetee/1478-force-delete-poll-message

Set single poll message for force delete
This commit is contained in:
Timo Võhmar 2020-01-22 14:22:17 +02:00 committed by GitHub
commit e920c75def
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 5 deletions

View file

@ -7,7 +7,9 @@ module Admin
domain.transaction do
domain.schedule_force_delete(type: force_delete_type)
domain.registrar.notifications.create!(text: t('force_delete_set_on_domain',
domain_name: domain.name))
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date))
notify_by_email if notify_by_email?
end

View file

@ -88,6 +88,15 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
registrar.notifications.create!(text: I18n.t('force_delete_cancelled', domain_name: name))
end
def outzone_date
(force_delete_start || valid_to) + Setting.expire_warning_period.days
end
def purge_date
(force_delete_date&.beginning_of_day || valid_to + Setting.expire_warning_period.days +
Setting.redemption_grace_period.days)
end
private
def calculate_soft_delete_date

View file

@ -5,9 +5,10 @@ module Concerns
class_methods do
def notify_client_hold(domain)
domain.registrar.notifications.create!(text: I18n.t('client_hold_set_on_domain',
domain.registrar.notifications.create!(text: I18n.t('force_delete_set_on_domain',
domain_name: domain.name,
date: domain.force_delete_start))
outzone_date: domain.outzone_date,
purge_date: domain.purge_date))
end
def notify_on_grace_period(domain)

View file

@ -618,8 +618,7 @@ en:
created_at_from: 'Created at from'
created_at_until: 'Created at until'
is_registrant: 'Is registrant'
force_delete_set_on_domain: 'Force delete set on domain %{domain_name}'
client_hold_set_on_domain: 'clientHold status is set for domain %{domain_name}, ForceDelete is in effect from %{date}'
force_delete_set_on_domain: 'Force delete set on domain %{domain_name}. Outzone date: %{outzone_date}. Purge date: %{purge_date}'
grace_period_started_domain: 'For domain %{domain_name} started 45-days redemption grace period, ForceDelete will be in effect from %{date}'
force_delete_cancelled: 'Force delete is cancelled on domain %{domain_name}'
contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact'

View file

@ -152,6 +152,35 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
assert_empty @domain.statuses & statuses
end
def test_hard_force_delete_should_have_outzone_and_purge_date_with_time
@domain.schedule_force_delete(type: :fast_track)
@domain.reload
assert_equal(@domain.purge_date.to_date, @domain.force_delete_date)
assert_equal(@domain.outzone_date.to_date, @domain.force_delete_start.to_date +
Setting.expire_warning_period.days)
assert(@domain.purge_date.is_a?(ActiveSupport::TimeWithZone))
assert(@domain.outzone_date.is_a?(ActiveSupport::TimeWithZone))
end
def test_soft_force_delete_year_ahead_should_have_outzone_and_purge_date_with_time
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
@domain.update(template_name: 'legal_person')
travel_to Time.zone.parse('2010-07-05')
@domain.schedule_force_delete(type: :soft)
travel_to Time.zone.parse('2010-08-21')
DomainCron.start_client_hold
@domain.reload
assert_equal(@domain.purge_date.to_date, @domain.force_delete_date.to_date)
assert_equal(@domain.outzone_date.to_date, @domain.force_delete_start.to_date +
Setting.expire_warning_period.days)
assert(@domain.purge_date.is_a?(ActiveSupport::TimeWithZone))
assert(@domain.outzone_date.is_a?(ActiveSupport::TimeWithZone))
end
def test_force_delete_soft_year_ahead_sets_client_hold
asserted_status = DomainStatus::CLIENT_HOLD