Refactor domain force delete, add "death" force delete mailer template

#268
This commit is contained in:
Artur Beljajev 2017-01-23 04:16:59 +02:00
parent ae5ae9c60b
commit b7a999f536
23 changed files with 395 additions and 166 deletions

View file

@ -1,6 +1,7 @@
class Admin::DomainsController < AdminController
load_and_authorize_resource
before_action :set_domain, only: [:show, :edit, :update, :zonefile]
helper_method :force_delete_templates
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
@ -59,22 +60,26 @@ class Admin::DomainsController < AdminController
end
end
def set_force_delete
if @domain.set_force_delete
flash[:notice] = I18n.t('domain_updated')
else
flash.now[:alert] = I18n.t('failed_to_update_domain')
def schedule_force_delete
raise 'Template param cannot be empty' if params[:template_name].blank?
@domain.transaction do
@domain.schedule_force_delete
@domain.registrar.messages.create!(body: I18n.t('force_delete_set_on_domain', domain_name: @domain.name))
DomainDeleteForcedEmailJob.enqueue(@domain.id, params[:template_name])
end
redirect_to [:admin, @domain]
redirect_to edit_admin_domain_path(@domain), notice: t('.scheduled')
end
def unset_force_delete
if @domain.unset_force_delete
flash[:notice] = I18n.t('domain_updated')
def cancel_force_delete
if @domain.cancel_force_delete
flash[:notice] = t('.cancelled')
else
flash.now[:alert] = I18n.t('failed_to_update_domain')
end
redirect_to [:admin, @domain]
redirect_to edit_admin_domain_path(@domain)
end
def versions
@ -121,5 +126,8 @@ class Admin::DomainsController < AdminController
params[:q][:valid_to_lteq] = ca_cache
end
end
def force_delete_templates
%w(removed_company death)
end
end

View file

@ -1,11 +1,12 @@
class DomainDeleteForcedEmailJob < Que::Job
def run(domain_id)
def run(domain_id, template_name)
domain = Domain.find(domain_id)
log(domain)
DomainDeleteMailer.forced(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant).deliver_now
registrant: domain.registrant,
template_name: template_name).deliver_now
end
private

View file

@ -8,12 +8,17 @@ class DomainDeleteMailer < ApplicationMailer
mail(to: registrant.email, subject: subject)
end
def forced(domain:, registrar:, registrant:)
def forced(domain:, registrar:, registrant:, template_name:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
mail(to: domain.primary_contact_emails)
@force_delete_set_date = Time.zone.now
@redemption_grace_period = Setting.redemption_grace_period
mail(to: domain.primary_contact_emails,
template_path: 'mailers/domain_delete_mailer/forced',
template_name: template_name)
end
private

View file

@ -5,15 +5,11 @@ module Concerns::Domain::ForceDelete
alias_attribute :force_delete_time, :force_delete_at
end
def force_deletable?
!statuses.include?(DomainStatus::FORCE_DELETE)
end
def force_delete?
def force_delete_scheduled?
statuses.include?(DomainStatus::FORCE_DELETE)
end
def set_force_delete
def schedule_force_delete
self.statuses_backup = statuses
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
@ -43,7 +39,7 @@ module Concerns::Domain::ForceDelete
save!(validate: false)
end
def unset_force_delete
def cancel_force_delete
s = []
s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED)
s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD)

View file

@ -136,7 +136,7 @@ class Domain < ActiveRecord::Base
validate :check_permissions, :unless => :is_admin
def check_permissions
return unless force_delete?
return unless force_delete_scheduled?
errors.add(:base, I18n.t(:object_status_prohibits_operation))
false
end

View file

@ -38,6 +38,24 @@ class DomainPresenter
domain.nameserver_hostnames.join(', ')
end
def force_delete_toggle_btn
if !domain.force_delete_scheduled?
view.content_tag(:a, view.t('admin.domains.force_delete_toggle_btn.schedule'),
class: 'btn btn-danger',
data: {
toggle: 'modal',
target: '.domain-edit-force-delete-dialog',
}
)
else
view.link_to(view.t('admin.domains.force_delete_toggle_btn.cancel'),
view.cancel_force_delete_admin_domain_path(domain),
method: :patch,
data: { confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confim') },
class: 'btn btn-primary')
end
end
private
attr_reader :domain

View file

@ -1,5 +1,5 @@
class RegistrantPresenter
delegate :name, :ident, :email, :priv?, :street, :city, to: :registrant
delegate :name, :ident, :email, :priv?, :street, :city, :id_code, to: :registrant
def initialize(registrant:, view:)
@registrant = registrant

View file

@ -1,3 +1,34 @@
<div class="domain-edit-force-delete-dialog">
test
<div class="modal domain-edit-force-delete-dialog" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><%= t '.title' %></h4>
</div>
<div class="modal-body">
<div class="row">
<%= form_tag schedule_force_delete_admin_domain_path, method: :patch,
id: 'domain-force-delete-form', class: 'form-horizontal' do %>
<div class="form-group">
<label class="col-sm-2 control-label"><%= t '.template' %>:</label>
<div class="col-sm-9">
<%= select_tag 'template_name', options_for_select(templates), class: 'form-control' %>
</div>
</div>
<% end %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t '.close_btn' %></button>
<button type="submit" form="domain-force-delete-form" class="btn btn-danger">
<%= t '.submit_btn' %>
</button>
</div>
</div>
</div>
</div>

View file

@ -1,17 +1,20 @@
<% content_for :actions do %>
<%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %>
<% domain = DomainPresenter.new(domain: @domain, view: self) %>
<% if @domain.force_deletable? %>
<%= link_to(t('.force_delete_btn'), force_delete_admin_domain_path(@domain),
method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %>
<% else %>
<%= link_to(t('.cancel_force_delete_btn'), cancel_force_delete_admin_domain_path(@domain),
method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %>
<% end %>
<div class="row">
<div class="col-sm-5">
<h1 class="text-center-xs">
Edit: <%= domain.name %>
</h1>
</div>
<div class="col-sm-7">
<h1 class="text-right text-center-xs">
<%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %>
<%= domain.force_delete_toggle_btn %>
<%= link_to t('.back_btn'), [:admin, @domain], class: 'btn btn-default' %>
</h1>
</div>
</div>
<hr>
<%= link_to t(:back_to_domain), [:admin, @domain], class: 'btn btn-default' %>
<% end %>
<%= render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" %>
<%= render 'form' %>
<%= render 'force_delete_dialog' %>
<%= render 'force_delete_dialog', templates: force_delete_templates %>

View file

@ -1,43 +1,57 @@
<p>Lugupeetud domeeni <%= @domain.name %> kontaktisik<br>
.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:</p>
<table width="600" cellspacing="0" cellpadding="0" border="0" align="center"><tbody>
<tr><td>
<table cellspacing="0" cellpadding="0" border="0" align="center" style="text-align: justify; line-height: 16px; font-size: 12px;"><tbody>
<tr><td>
<br />
<p><strong>Lugupeetud domeeni <%= @domain.name %> kontaktisik</strong></p>
<p>.ee domeeniregistrisse on domeeni <strong><%= @domain.name %></strong> kohta kantud järgmised andmed:</p>
<p>Registreerija nimi: <%= @registrant.name %><br>
Isikukood: <%= @registrant.id_code %></p>
<p>Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud.
<p>Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud.</p>
Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale [Registrars.name] domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul.
<p>Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @registrar.name %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul.</p>
Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine.
<p>Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine.</p>
Kui üleandmine ei ole <%= @redemption_grace_period %> päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.
<p>Kui üleandmine ei ole <%= @redemption_grace_period %> päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.</p>
Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<hr>
<p>Dear contact of <%= @domain.name %> domain<br>
The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIS) domain registry:</p>
<p><strong>Dear contact of <%= @domain.name %> domain</strong><br>
The following details for domain name <strong><%= @domain.name %></strong> have been entered into the Estonian Internet Foundation's (EIS) domain registry:</p>
<p>Registrant's name: <%= @registrant.name %><br>
Identification code: <%= @registrant.id_code %></p>
<p>EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death.
<p>EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death.</p>
According to paragraph 6.6 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar [Registrars.name] in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar within <%= @redemption_grace_period %> day(s).
<p>According to paragraph 6.6 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @registrar.name %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar within <%= @redemption_grace_period %> day(s).</p>
As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant.
<p>As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant.</p>
If the transfer has not been made in <%= @redemption_grace_period %> day(s), the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_date %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.
<p>If the transfer has not been made in <%= @redemption_grace_period %> day(s), the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_date %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.</p>
Should you have additional questions, please contact your registrar:</p>
<p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<p>Lugupidamisega,<br>
Best Regards,<br>
<br><br>
Eesti Interneti Sihtasutus<br>
Estonian Internet Foundation</p>
<br /><br />
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="text-align: justify; line-height: 16px; font-size: 12px;"><tbody>
<tr><td align="left" valign="top">
<p><strong>Lugupidamisega,<br />
Best Regards,</strong></p>
<p><i>Eesti Interneti Sihtasutus<br />
Estonian Internet Foundation</i></p>
</td><td></td></tr>
</tbody>
</table>
</td></tr>
</tbody></table></table>

View file

@ -6,7 +6,7 @@ Isikukood: <%= @registrant.id_code %>
Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud.
Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale [Registrars.name] domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul.
Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @registrar.name %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul.
Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine.
@ -27,7 +27,7 @@ Identification code: <%= @registrant.id_code %>
EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death.
According to paragraph 6.6 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar [Registrars.name] in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar within <%= @redemption_grace_period %> day(s).
According to paragraph 6.6 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @registrar.name %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar within <%= @redemption_grace_period %> day(s).
As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant.