Merge pull request #352 from internetee/registry-268

Registry 268
This commit is contained in:
Timo Võhmar 2017-01-23 16:05:28 +02:00 committed by GitHub
commit c8d8b1f9eb
42 changed files with 589 additions and 221 deletions

View file

@ -10,5 +10,5 @@
#= require select2 #= require select2
#= require jquery.doubleScroll #= require jquery.doubleScroll
#= require admin/application #= require admin/application
#= require admin/combobox #= require admin/app
#= require admin/datepicker #= require_tree ./admin

View file

@ -0,0 +1 @@
var RegistryAdmin = {};

View file

@ -5,10 +5,10 @@
//= require 'select2-bootstrap' //= require 'select2-bootstrap'
@import shared/fonts @import shared/fonts
@import shared/general @import shared/general
@import nprogress
@import nprogress-bootstrap
@import typeaheadjs @import typeaheadjs
@import selectize @import selectize
@import selectize.bootstrap3 @import selectize.bootstrap3
// @import bootstrap-datepicker3 // @import bootstrap-datepicker3
@import admin/admin @import admin/admin
@import admin/bootstrap-dialog-fix

View file

@ -0,0 +1,7 @@
.modal-open {
overflow: visible;
}
.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom {
padding-right: 0px !important;
}

View file

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

View file

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

View file

@ -8,12 +8,17 @@ class DomainDeleteMailer < ApplicationMailer
mail(to: registrant.email, subject: subject) mail(to: registrant.email, subject: subject)
end end
def forced(domain:, registrar:, registrant:) def forced(domain:, registrar:, registrant:, template_name:)
@domain = DomainPresenter.new(domain: domain, view: view_context) @domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, 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 end
private private

View file

@ -0,0 +1,54 @@
module Concerns::Domain::ForceDelete
extend ActiveSupport::Concern
included do
alias_attribute :force_delete_time, :force_delete_at
end
def force_delete_scheduled?
statuses.include?(DomainStatus::FORCE_DELETE)
end
def schedule_force_delete
self.statuses_backup = statuses
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
statuses.delete(DomainStatus::PENDING_UPDATE)
statuses.delete(DomainStatus::PENDING_TRANSFER)
statuses.delete(DomainStatus::PENDING_RENEW)
statuses.delete(DomainStatus::PENDING_CREATE)
statuses.delete(DomainStatus::FORCE_DELETE)
statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_MANUAL_INZONE)
statuses.delete(DomainStatus::PENDING_DELETE)
statuses << DomainStatus::FORCE_DELETE
statuses << DomainStatus::SERVER_RENEW_PROHIBITED
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
statuses << DomainStatus::PENDING_DELETE
if (statuses & [DomainStatus::SERVER_HOLD, DomainStatus::CLIENT_HOLD]).empty?
statuses << DomainStatus::SERVER_MANUAL_INZONE
end
self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc.beginning_of_day unless force_delete_at
save!(validate: false)
end
def cancel_force_delete
s = []
s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED)
s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD)
s << DomainStatus::DELETE_CANDIDATE if statuses.include?(DomainStatus::DELETE_CANDIDATE)
self.statuses = (statuses_backup + s).uniq
self.force_delete_at = nil
self.statuses_backup = []
save(validate: false)
end
end

View file

@ -1,7 +0,0 @@
module Statuses
extend ActiveSupport::Concern
def force_delete?
statuses.include?(DomainStatus::FORCE_DELETE)
end
end

View file

@ -589,4 +589,9 @@ class Contact < ActiveRecord::Base
return if priv? return if priv?
ident ident
end end
def id_code
return unless priv?
ident
end
end end

View file

@ -2,9 +2,9 @@
class Domain < ActiveRecord::Base class Domain < ActiveRecord::Base
include UserEvents include UserEvents
include Versions # version/domain_version.rb include Versions # version/domain_version.rb
include Statuses
include Concerns::Domain::Expirable include Concerns::Domain::Expirable
include Concerns::Domain::Activatable include Concerns::Domain::Activatable
include Concerns::Domain::ForceDelete
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
@ -13,7 +13,6 @@ class Domain < ActiveRecord::Base
attr_accessor :legal_document_id attr_accessor :legal_document_id
alias_attribute :on_hold_time, :outzone_at alias_attribute :on_hold_time, :outzone_at
alias_attribute :force_delete_time, :force_delete_at
alias_attribute :outzone_time, :outzone_at alias_attribute :outzone_time, :outzone_at
alias_attribute :delete_time, :delete_at alias_attribute :delete_time, :delete_at
@ -137,7 +136,7 @@ class Domain < ActiveRecord::Base
validate :check_permissions, :unless => :is_admin validate :check_permissions, :unless => :is_admin
def check_permissions def check_permissions
return unless force_delete? return unless force_delete_scheduled?
errors.add(:base, I18n.t(:object_status_prohibits_operation)) errors.add(:base, I18n.t(:object_status_prohibits_operation))
false false
end end
@ -422,10 +421,6 @@ class Domain < ActiveRecord::Base
end end
# rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/CyclomaticComplexity
def force_deletable?
!statuses.include?(DomainStatus::FORCE_DELETE)
end
def registrant_verification_asked? def registrant_verification_asked?
registrant_verification_asked_at.present? && registrant_verification_token.present? registrant_verification_asked_at.present? && registrant_verification_token.present?
end end
@ -538,64 +533,6 @@ class Domain < ActiveRecord::Base
end end
# rubocop:enable Lint/Loop # rubocop:enable Lint/Loop
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def set_force_delete
self.statuses_backup = statuses
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
statuses.delete(DomainStatus::PENDING_UPDATE)
statuses.delete(DomainStatus::PENDING_TRANSFER)
statuses.delete(DomainStatus::PENDING_RENEW)
statuses.delete(DomainStatus::PENDING_CREATE)
statuses.delete(DomainStatus::FORCE_DELETE)
statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_MANUAL_INZONE)
statuses.delete(DomainStatus::PENDING_DELETE)
statuses << DomainStatus::FORCE_DELETE
statuses << DomainStatus::SERVER_RENEW_PROHIBITED
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
statuses << DomainStatus::PENDING_DELETE
if (statuses & [DomainStatus::SERVER_HOLD, DomainStatus::CLIENT_HOLD]).empty?
statuses << DomainStatus::SERVER_MANUAL_INZONE
end
self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc.beginning_of_day unless force_delete_at
transaction do
save!(validate: false)
registrar.messages.create!(
body: I18n.t('force_delete_set_on_domain', domain: name)
)
DomainDeleteForcedEmailJob.enqueue(id)
return true
end
false
end
# rubocop: enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize
def unset_force_delete
s = []
s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED)
s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD)
s << DomainStatus::DELETE_CANDIDATE if statuses.include?(DomainStatus::DELETE_CANDIDATE)
self.statuses = (statuses_backup + s).uniq
self.force_delete_at = nil
self.statuses_backup = []
save(validate: false)
end
def set_graceful_expired def set_graceful_expired
self.outzone_at = expire_time + self.class.expire_warning_period self.outzone_at = expire_time + self.class.expire_warning_period
self.delete_at = outzone_at + self.class.redemption_grace_period self.delete_at = outzone_at + self.class.redemption_grace_period

View file

@ -38,6 +38,24 @@ class DomainPresenter
domain.nameserver_hostnames.join(', ') domain.nameserver_hostnames.join(', ')
end 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 private
attr_reader :domain attr_reader :domain

View file

@ -1,5 +1,5 @@
class RegistrantPresenter 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:) def initialize(registrant:, view:)
@registrant = registrant @registrant = registrant

View file

@ -0,0 +1,20 @@
<% if flash[:notice] %>
<div class="alert alert-success alert-dismissible">
<button class="close" data-dismiss="alert" type=button><span>&times;</span></button>
<p><%= flash[:notice] %></p>
</div>
<% end %>
<% if flash[:alert] %>
<div class="alert alert-danger alert-dismissible">
<button class="close" data-dismiss="alert" type=button><span>&times;</span></button>
<p><%= flash[:alert] %></p>
</div>
<% end %>
<% if flash[:info] %>
<div class="alert alert-info alert-dismissible">
<button class="close" data-dismiss="alert" type=button><span>&times;</span></button>
<p><%= flash[:info] %></p>
</div>
<% end %>

View file

@ -0,0 +1,34 @@
<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,13 +0,0 @@
- content_for :actions do
= link_to(t(:add_new_status), '#', class: 'btn btn-primary js-add-status')
- if @domain.force_deletable?
= link_to(t(:set_force_delete), set_force_delete_admin_domain_path(@domain),
method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning')
- else
= link_to(t(:unset_force_delete), unset_force_delete_admin_domain_path(@domain),
method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning')
= link_to(t(:back_to_domain), [:admin, @domain], class: 'btn btn-default')
= render 'shared/title', name: "#{t(:edit)}: #{@domain.name}"
= render 'form'

View file

@ -0,0 +1,20 @@
<% domain = DomainPresenter.new(domain: @domain, view: self) %>
<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>
<%= render 'form' %>
<%= render 'force_delete_dialog', templates: force_delete_templates %>

View file

@ -27,7 +27,7 @@
= render 'menu' = render 'menu'
.container .container
= render 'shared/flash' = render 'flash_messages'
= yield = yield
.footer.text-right .footer.text-right

View file

@ -0,0 +1,57 @@
<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>
<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>
<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>
<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>
<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<hr>
<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>
<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>
<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>
<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>
<p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<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

@ -0,0 +1,44 @@
Lugupeetud domeeni <%= @domain.name %> kontaktisik
.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:
Registreerija nimi: <%= @registrant.name %>
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 <%= @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.
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.
Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Dear contact of <%= @domain.name %> domain
The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIS) domain registry:
Registrant's name: <%= @registrant.name %>
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 <%= @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.
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.
Should you have additional questions, please contact your registrar:
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
Lugupidamisega,
Best Regards,
Eesti Interneti Sihtasutus
Estonian Internet Foundation

View file

@ -1,4 +0,0 @@
- display = (flash.empty?) ? 'none' : 'block'
#flash{style: "display: #{display};"}
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
.alert{class: type}= flash[:notice] || flash[:alert]

View file

@ -24,7 +24,7 @@ Rails.application.configure do
# Debug mode disables concatenation and preprocessing of assets. # Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large # This option may cause significant delays in view rendering with a large
# number of complex assets. # number of complex assets.
config.assets.debug = true config.assets.debug = false
# Adds additional error checking when serving assets at runtime. # Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies. # Checks for improperly declared sprockets dependencies.

View file

@ -4,6 +4,22 @@ en:
index: index:
reset_btn: Reset reset_btn: Reset
edit:
add_new_status_btn: Add new status
back_btn: Back to domain
force_delete_dialog:
title: Force delete
template: Template
close_btn: Close dialog
submit_btn: Force delete domain
schedule_force_delete:
scheduled: Force delete procedure has been scheduled
cancel_force_delete:
cancelled: Force delete procedure has been cancelled
versions: versions:
time: Time time: Time
admin_contact: Admin contact admin_contact: Admin contact
@ -13,3 +29,8 @@ en:
outzone_time: Outzone time outzone_time: Outzone time
delete_time: Delete time delete_time: Delete time
force_delete_time: Force delete time force_delete_time: Force delete time
force_delete_toggle_btn:
schedule: Schedule force delete
cancel: Cancel force delete
cancel_confim: Are you sure you want cancel force delete procedure?

View file

@ -602,7 +602,6 @@ en:
new_domain: 'New domain' new_domain: 'New domain'
edit: 'Edit' edit: 'Edit'
delete: 'Delete' delete: 'Delete'
are_you_sure: 'Are you sure?'
renew: 'Renew' renew: 'Renew'
new: New new: New
renew_domain: 'Renew domain' renew_domain: 'Renew domain'
@ -844,8 +843,6 @@ en:
valid: Valid valid: Valid
category: Zone category: Zone
object_is_not_eligible_for_renewal: 'Object is not eligible for renewal' object_is_not_eligible_for_renewal: 'Object is not eligible for renewal'
set_force_delete: 'Set force delete'
unset_force_delete: 'Unset force delete'
domain_expiring: 'Domain expiring' domain_expiring: 'Domain expiring'
domain_validation_rules: 'Domain validation rules' domain_validation_rules: 'Domain validation rules'
bank_statement_desc: 'Import file row will match only when matching following attributes: <b><br>ref number<br>payment amount<br>invoice number (the first numerical value in comment field)</b>.' bank_statement_desc: 'Import file row will match only when matching following attributes: <b><br>ref number<br>payment amount<br>invoice number (the first numerical value in comment field)</b>.'
@ -914,7 +911,7 @@ en:
created_at_from: 'Created at from' created_at_from: 'Created at from'
created_at_until: 'Created at until' created_at_until: 'Created at until'
is_registrant: 'Is registrant' is_registrant: 'Is registrant'
force_delete_set_on_domain: 'Force delete set on domain %{domain}' force_delete_set_on_domain: 'Force delete set on domain %{domain_name}'
mail_templates: Mail Templates mail_templates: Mail Templates
new_mail_template: New mail template new_mail_template: New mail template
failure: "It was not saved" failure: "It was not saved"

View file

@ -202,9 +202,10 @@ Rails.application.routes.draw do
resources :domain_versions, controller: 'domains', action: 'versions' resources :domain_versions, controller: 'domains', action: 'versions'
resources :pending_updates resources :pending_updates
resources :pending_deletes resources :pending_deletes
member do member do
post 'set_force_delete' patch 'schedule_force_delete'
post 'unset_force_delete' patch 'cancel_force_delete'
end end
end end

View file

@ -10,5 +10,10 @@ FactoryGirl.define do
domain.admin_domain_contacts << FactoryGirl.build(:admin_domain_contact) domain.admin_domain_contacts << FactoryGirl.build(:admin_domain_contact)
domain.tech_domain_contacts << FactoryGirl.build(:tech_domain_contact) domain.tech_domain_contacts << FactoryGirl.build(:tech_domain_contact)
end end
factory :domain_without_force_delete do
force_delete_time nil
statuses []
end
end end
end end

View file

@ -0,0 +1,33 @@
require 'rails_helper'
RSpec.feature 'Force delete' do
context 'when domain has no force delete procedure' do
given!(:domain) { create(:domain_without_force_delete) }
scenario 'schedule' do
sign_in_to_admin_area
visit edit_admin_domain_url(domain)
click_link_or_button 'Force delete domain'
expect(page).to have_text('Force delete procedure has been scheduled')
end
end
context 'when domain has force delete procedure' do
given!(:domain) { create(:domain_without_force_delete) }
background do
domain.schedule_force_delete
end
scenario 'cancel' do
sign_in_to_admin_area
visit edit_admin_domain_url(domain)
click_link_or_button 'Cancel force delete'
expect(page).to have_text('Force delete procedure has been cancelled')
end
end
end

View file

@ -17,7 +17,8 @@ RSpec.describe DomainDeleteForcedEmailJob do
after :example do after :example do
domain_id = 1 domain_id = 1
described_class.enqueue(domain_id) template_name = 'removed_company'
described_class.enqueue(domain_id, template_name)
end end
it 'creates log record' do it 'creates log record' do
@ -32,7 +33,8 @@ RSpec.describe DomainDeleteForcedEmailJob do
it 'sends email' do it 'sends email' do
expect(DomainDeleteMailer).to receive(:forced).with(domain: domain, expect(DomainDeleteMailer).to receive(:forced).with(domain: domain,
registrar: 'registrar', registrar: 'registrar',
registrant: 'registrant') registrant: 'registrant',
template_name: 'removed_company')
.and_return(message) .and_return(message)
expect(message).to receive(:deliver_now) expect(message).to receive(:deliver_now)
end end

View file

@ -48,12 +48,16 @@ RSpec.describe DomainDeleteMailer do
describe '#forced' do describe '#forced' do
let(:domain) { instance_spy(Domain, name: 'test.com') } let(:domain) { instance_spy(Domain, name: 'test.com') }
let(:registrant) { instance_spy(Registrant) }
let(:template_name) { 'removed_company' }
let(:domain_presenter) { instance_spy(DomainPresenter) } let(:domain_presenter) { instance_spy(DomainPresenter) }
let(:registrar_presenter) { instance_spy(RegistrarPresenter) } let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
let(:registrant_presenter) { instance_spy(RegistrantPresenter) } let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
subject(:message) { described_class.forced(domain: domain, subject(:message) { described_class.forced(domain: domain,
registrar: 'registrar', registrar: 'registrar',
registrant: 'registrant') registrant: registrant,
template_name: template_name)
} }
before :example do before :example do
@ -75,8 +79,28 @@ RSpec.describe DomainDeleteMailer do
expect(message.subject).to eq('Kustutusmenetluse teade') expect(message.subject).to eq('Kustutusmenetluse teade')
end end
it 'sends message' do context 'when template is :death' do
expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) let(:template_name) { 'death' }
it 'sends message' do
expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
context 'when registrant is private entity' do
let(:registrant) { build_stubbed(:registrant_private_entity) }
it 'sends message' do
expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
context 'when registrant is legal entity' do
let(:registrant) { build_stubbed(:registrant_legal_entity) }
it 'sends message' do
expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end end
end end
end end

View file

@ -0,0 +1,98 @@
require 'rails_helper'
RSpec.describe Domain do
it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) }
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
end
it 'should set force delete time' do
domain = Fabricate(:domain)
domain.statuses = ['ok']
domain.schedule_force_delete
domain.statuses.should match_array([
"serverForceDelete",
"pendingDelete",
"serverManualInzone",
"serverRenewProhibited",
"serverTransferProhibited",
"serverUpdateProhibited"
])
domain.cancel_force_delete
domain.statuses.should == ['ok']
domain.statuses = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::PENDING_UPDATE,
DomainStatus::PENDING_TRANSFER,
DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_CREATE,
DomainStatus::CLIENT_HOLD,
DomainStatus::EXPIRED,
DomainStatus::SERVER_HOLD,
DomainStatus::DELETE_CANDIDATE
]
domain.save
domain.schedule_force_delete
domain.statuses.should match_array([
"clientHold",
"deleteCandidate",
"expired",
"serverForceDelete",
"pendingDelete",
"serverHold",
"serverRenewProhibited",
"serverTransferProhibited",
"serverUpdateProhibited"
])
domain.cancel_force_delete
domain.statuses.should match_array([
"clientDeleteProhibited",
"clientHold",
"deleteCandidate",
"expired",
"pendingCreate",
"pendingRenew",
"pendingTransfer",
"pendingUpdate",
"serverDeleteProhibited",
"serverHold"
])
end
it 'should should be manual in zone and held after force delete' do
domain = create(:domain)
Setting.redemption_grace_period = 1
domain.valid?
domain.outzone_at = Time.zone.now + 1.day # before redemption grace period
# what should this be?
# domain.server_holdable?.should be true
domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false
domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be false
domain.schedule_force_delete
domain.server_holdable?.should be false
domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be true
domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false
end
it 'should not allow update after force delete' do
domain = create(:domain)
domain.valid?
domain.pending_update_prohibited?.should be false
domain.update_prohibited?.should be false
domain.schedule_force_delete
domain.pending_update_prohibited?.should be true
domain.update_prohibited?.should be true
end
end

View file

@ -481,4 +481,18 @@ RSpec.describe Contact, db: false do
specify { expect(reg_no).to be_nil } specify { expect(reg_no).to be_nil }
end end
end end
describe '#id_code' do
context 'when contact is private entity' do
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
specify { expect(contact.id_code).to eq('1234') }
end
context 'when contact is legal entity' do
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
specify { expect(contact.id_code).to be_nil }
end
end
end end

View file

@ -182,98 +182,6 @@ RSpec.describe Domain do
domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
end end
it 'should set force delete time' do
@domain.statuses = ['ok']
@domain.set_force_delete
@domain.statuses.should match_array([
"serverForceDelete",
"pendingDelete",
"serverManualInzone",
"serverRenewProhibited",
"serverTransferProhibited",
"serverUpdateProhibited"
])
fda = Time.zone.now + Setting.redemption_grace_period.days
@domain.registrar.messages.count.should == 1
m = @domain.registrar.messages.first
m.body.should == "Force delete set on domain #{@domain.name}"
@domain.unset_force_delete
@domain.statuses.should == ['ok']
@domain.statuses = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::PENDING_UPDATE,
DomainStatus::PENDING_TRANSFER,
DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_CREATE,
DomainStatus::CLIENT_HOLD,
DomainStatus::EXPIRED,
DomainStatus::SERVER_HOLD,
DomainStatus::DELETE_CANDIDATE
]
@domain.save
@domain.set_force_delete
@domain.statuses.should match_array([
"clientHold",
"deleteCandidate",
"expired",
"serverForceDelete",
"pendingDelete",
"serverHold",
"serverRenewProhibited",
"serverTransferProhibited",
"serverUpdateProhibited"
])
@domain.unset_force_delete
@domain.statuses.should match_array([
"clientDeleteProhibited",
"clientHold",
"deleteCandidate",
"expired",
"pendingCreate",
"pendingRenew",
"pendingTransfer",
"pendingUpdate",
"serverDeleteProhibited",
"serverHold"
])
end
it 'should should be manual in zone and held after force delete' do
Setting.redemption_grace_period = 1
@domain.valid?
@domain.outzone_at = Time.zone.now + 1.day # before redemption grace period
# what should this be?
# @domain.server_holdable?.should be true
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false
@domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be false
@domain.set_force_delete
@domain.server_holdable?.should be false
@domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be true
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false
end
it 'should not allow update after force delete' do
@domain.valid?
@domain.pending_update_prohibited?.should be false
@domain.update_prohibited?.should be false
@domain.set_force_delete
@domain.pending_update_prohibited?.should be true
@domain.update_prohibited?.should be true
end
context 'with time period settings' do context 'with time period settings' do
before :example do before :example do
@save_days_to_renew = Setting.days_to_renew_domain_before_expire @save_days_to_renew = Setting.days_to_renew_domain_before_expire
@ -302,7 +210,7 @@ RSpec.describe Domain do
it 'should not allow to renew after force delete' do it 'should not allow to renew after force delete' do
Setting.redemption_grace_period = 1 Setting.redemption_grace_period = 1
@domain.set_force_delete @domain.schedule_force_delete
@domain.renewable?.should be false @domain.renewable?.should be false
end end
end end
@ -327,7 +235,7 @@ RSpec.describe Domain do
it 'should not allow to renew after force delete' do it 'should not allow to renew after force delete' do
Setting.redemption_grace_period = 1 Setting.redemption_grace_period = 1
@domain.set_force_delete @domain.schedule_force_delete
@domain.renewable?.should be false @domain.renewable?.should be false
end end
end end
@ -700,7 +608,6 @@ end
RSpec.describe Domain, db: false do RSpec.describe Domain, db: false do
it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) } it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) }
it { is_expected.to alias_attribute(:delete_time, :delete_at) } it { is_expected.to alias_attribute(:delete_time, :delete_at) }
it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) }
it { is_expected.to alias_attribute(:outzone_time, :outzone_at) } it { is_expected.to alias_attribute(:outzone_time, :outzone_at) }
describe 'nameserver validation', db: true do describe 'nameserver validation', db: true do

View file

@ -114,6 +114,40 @@ RSpec.describe DomainPresenter do
end end
end end
describe '#force_delete_toggle_btn' do
let(:domain) { build_stubbed(:domain) }
context 'when force delete is not scheduled' do
before :example do
expect(domain).to receive(:force_delete_scheduled?).and_return(false)
end
it 'returns schedule button' do
html = view.content_tag(:a, 'Schedule force delete',
class: 'btn btn-danger',
data: {
toggle: 'modal',
target: '.domain-edit-force-delete-dialog',
})
expect(presenter.force_delete_toggle_btn).to eq(html)
end
end
context 'when force delete is scheduled' do
before :example do
expect(domain).to receive(:force_delete_scheduled?).and_return(true)
end
it 'returns cancel button' do
html = link_to('Cancel force delete',
view.cancel_force_delete_admin_domain_path(domain),
method: :patch,
data: { confirm: 'Are you sure you want cancel force delete procedure?' },
class: 'btn btn-primary')
expect(presenter.force_delete_toggle_btn).to eq(html)
end
end
end
domain_delegatable_attributes = %i( domain_delegatable_attributes = %i(
name name

View file

@ -11,6 +11,7 @@ RSpec.describe RegistrantPresenter do
priv? priv?
street street
city city
id_code
) )
registrant_delegate_attributes.each do |attribute_name| registrant_delegate_attributes.each do |attribute_name|

View file

@ -0,0 +1,13 @@
require 'rails_helper'
RSpec.describe Admin::DomainsController do
describe 'routing' do
it 'routes to #schedule_force_delete' do
expect(patch: '/admin/domains/1/schedule_force_delete').to route_to('admin/domains#schedule_force_delete', id: '1')
end
it 'routes to #cancel_force_delete' do
expect(patch: '/admin/domains/1/cancel_force_delete').to route_to('admin/domains#cancel_force_delete', id: '1')
end
end
end

View file

@ -1,5 +1,14 @@
module Features module Features
module SessionHelpers module SessionHelpers
def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user))
visit admin_login_url
fill_in 'admin_user[username]', with: user.username
fill_in 'admin_user[password]', with: user.password
click_button 'Log in'
end
def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user)) def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user))
visit registrar_login_url visit registrar_login_url

View file

@ -0,0 +1,22 @@
require 'rails_helper'
RSpec.describe 'admin/domains/edit' do
let(:domain) { build_stubbed(:domain) }
let(:domain_presenter) { DomainPresenter.new(domain: domain, view: view) }
before :example do
allow(DomainPresenter).to receive(:new).and_return(domain_presenter)
allow(view).to receive(:force_delete_templates)
assign(:domain, domain)
stub_template '_form' => ''
stub_template '_force_delete_dialog' => ''
end
it 'has force_delete_toggle_btn' do
expect(domain_presenter).to receive(:force_delete_toggle_btn).and_return('force_delete_toggle_btn')
render
expect(rendered).to have_content('force_delete_toggle_btn')
end
end

View file

@ -1,7 +1,7 @@
require 'rails_helper' require 'rails_helper'
require_relative 'forced_shared' require_relative 'removed_company'
RSpec.describe 'mailers/domain_delete_mailer/forced.html.erb' do RSpec.describe 'mailers/domain_delete_mailer/forced/removed_company.html.erb' do
before :example do before :example do
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'

View file

@ -1,7 +1,7 @@
require 'rails_helper' require 'rails_helper'
require_relative 'forced_shared' require_relative 'removed_company'
RSpec.describe 'mailers/domain_delete_mailer/forced.text.erb' do RSpec.describe 'mailers/domain_delete_mailer/forced/removed_company.text.erb' do
before :example do before :example do
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'