Add mail notification on soft force delete

This commit is contained in:
Alex Sherman 2020-01-15 16:00:56 +05:00
parent 9916ca52cb
commit c252d801f9
10 changed files with 97 additions and 34 deletions

View file

@ -9,17 +9,21 @@ module Admin
domain.registrar.notifications.create!(text: t('force_delete_set_on_domain',
domain_name: domain.name))
if notify_by_email?
DomainDeleteMailer.forced(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant,
template_name: params[:template_name]).deliver_now
end
notify_by_email if notify_by_email?
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: params[:template_name])
end
end
def destroy
authorize! :manage, domain
domain.cancel_force_delete
@ -36,6 +40,13 @@ 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: params[:template_name]).deliver_now
end
def force_delete_type
soft_delete? ? :soft : :fast_track
end