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 jquery.doubleScroll
#= require admin/application
#= require admin/combobox
#= require admin/datepicker
#= require admin/app
#= require_tree ./admin

View file

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

View file

@ -5,10 +5,10 @@
//= require 'select2-bootstrap'
@import shared/fonts
@import shared/general
@import nprogress
@import nprogress-bootstrap
@import typeaheadjs
@import selectize
@import selectize.bootstrap3
// @import bootstrap-datepicker3
@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
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

@ -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?
ident
end
def id_code
return unless priv?
ident
end
end

View file

@ -2,9 +2,9 @@
class Domain < ActiveRecord::Base
include UserEvents
include Versions # version/domain_version.rb
include Statuses
include Concerns::Domain::Expirable
include Concerns::Domain::Activatable
include Concerns::Domain::ForceDelete
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
@ -13,7 +13,6 @@ class Domain < ActiveRecord::Base
attr_accessor :legal_document_id
alias_attribute :on_hold_time, :outzone_at
alias_attribute :force_delete_time, :force_delete_at
alias_attribute :outzone_time, :outzone_at
alias_attribute :delete_time, :delete_at
@ -137,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
@ -422,10 +421,6 @@ class Domain < ActiveRecord::Base
end
# rubocop: enable Metrics/CyclomaticComplexity
def force_deletable?
!statuses.include?(DomainStatus::FORCE_DELETE)
end
def registrant_verification_asked?
registrant_verification_asked_at.present? && registrant_verification_token.present?
end
@ -538,64 +533,6 @@ class Domain < ActiveRecord::Base
end
# 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
self.outzone_at = expire_time + self.class.expire_warning_period
self.delete_at = outzone_at + self.class.redemption_grace_period

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

@ -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'
.container
= render 'shared/flash'
= render 'flash_messages'
= yield
.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]