mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Merge pull request #1741 from internetee/1740-interactor-force-delete
Refactor ForceDelete procedure to use interactor design pattern
This commit is contained in:
commit
3441387430
15 changed files with 164 additions and 98 deletions
|
@ -4,26 +4,15 @@ module Admin
|
|||
def create
|
||||
authorize! :manage, domain
|
||||
|
||||
notice = t('.scheduled')
|
||||
|
||||
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,
|
||||
outzone_date: domain.outzone_date,
|
||||
purge_date: domain.purge_date))
|
||||
|
||||
notify_by_email if notify_by_email?
|
||||
result = domain.schedule_force_delete(type: force_delete_type,
|
||||
notify_by_email: notify_by_email?)
|
||||
notice = result.errors.messages[:domain].first unless result.valid?
|
||||
end
|
||||
|
||||
redirect_to edit_admin_domain_url(domain), notice: t('.scheduled')
|
||||
end
|
||||
|
||||
def notify_by_email
|
||||
if force_delete_type == :fast_track
|
||||
send_email
|
||||
domain.update(contact_notification_sent_date: Time.zone.today)
|
||||
else
|
||||
domain.update(template_name: domain.notification_template)
|
||||
end
|
||||
redirect_to edit_admin_domain_url(domain), notice: notice
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -42,13 +31,6 @@ module Admin
|
|||
ActiveRecord::Type::Boolean.new.cast(params[:notify_by_email])
|
||||
end
|
||||
|
||||
def send_email
|
||||
DomainDeleteMailer.forced(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
registrant: domain.registrant,
|
||||
template_name: domain.notification_template).deliver_now
|
||||
end
|
||||
|
||||
def force_delete_type
|
||||
soft_delete? ? :soft : :fast_track
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue