Added pending delete

This commit is contained in:
Priit Tark 2015-05-18 16:45:34 +03:00
parent 50d36cb654
commit 6f59824cd1
13 changed files with 184 additions and 27 deletions

View file

@ -35,7 +35,7 @@ class Epp::DomainsController < EppController
if @domain.update(params[:parsed_frame], current_user)
if @domain.epp_pending_update.present?
render_epp_response '/epp/shared/success_pending'
render_epp_response '/epp/domains/success_pending'
else
render_epp_response '/epp/domains/success'
end
@ -56,9 +56,15 @@ class Epp::DomainsController < EppController
@domain.attach_legal_document(Epp::Domain.parse_legal_document_from_frame(params[:parsed_frame]))
@domain.save(validate: false)
handle_errors(@domain) and return unless @domain.destroy
render_epp_response '/epp/domains/success'
if @domain.epp_destroy(params[:parsed_frame])
if @domain.epp_pending_delete.present?
render_epp_response '/epp/domains/success_pending'
else
render_epp_response '/epp/domains/success'
end
else
handle_errors(@domain)
end
end
# rubocop:enbale Metrics/CyclomaticComplexity

View file

@ -1,5 +1,5 @@
class DomainMailer < ApplicationMailer
def registrant_updated(domain)
def registrant_pending_updated(domain)
@domain = domain
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
@ -22,6 +22,32 @@ class DomainMailer < ApplicationMailer
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_registrant_update_subject, name: @domain.name)} [#{@domain.name}]")
subject: "#{I18n.t(:domain_registrant_pending_updated_subject, name: @domain.name)} [#{@domain.name}]")
end
def pending_deleted(domain)
@domain = domain
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
# turn on delivery on specific request only, thus rake tasks does not deliver anything
return if @domain.deliver_emails != true
if @domain.registrant_verification_token.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
return
end
if @domain.registrant_verification_asked_at.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}"
return
end
@old_registrant = Registrant.find(@domain.registrant_id_was)
confirm_path = "#{ENV['registrant_url']}/registrant/domain_delete_confirms"
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_pending_deleted_subject, name: @domain.name)} [#{@domain.name}]")
end
end

View file

@ -117,7 +117,8 @@ class Domain < ActiveRecord::Base
validate :validate_nameserver_ips
attr_accessor :registrant_typeahead, :update_me, :deliver_emails, :epp_pending_update
attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
:epp_pending_update, :epp_pending_delete
def subordinate_nameservers
nameservers.select { |x| x.hostname.end_with?(name) }
@ -176,11 +177,11 @@ class Domain < ActiveRecord::Base
def pending_update!
return true if pending_update?
self.epp_pending_update = true # for handling epp errors correctly
self.epp_pending_update = true # for epp
return true unless registrant_verification_asked?
pending_json_cache = all_changes
DomainMailer.registrant_updated(self).deliver_now
DomainMailer.registrant_pending_updated(self).deliver_now
reload # revert back to original
@ -206,6 +207,21 @@ class Domain < ActiveRecord::Base
self.registrant_verification_token = SecureRandom.hex(42)
end
def pending_delete?
(domain_statuses.pluck(:value) & %W(
#{DomainStatus::PENDING_DELETE}
)).present?
end
def pending_delete!
return true if pending_delete?
self.epp_pending_delete = true # for epp
return true unless registrant_verification_asked?
domain_statuses.create(value: DomainStatus::PENDING_DELETE)
DomainMailer.pending_deleted(self).deliver_now
end
### VALIDATIONS ###
def validate_nameserver_ips

View file

@ -4,7 +4,7 @@ class Epp::Domain < Domain
before_validation :manage_permissions
def manage_permissions
return unless pending_update?
return unless pending_update? || pending_delete?
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
false
end
@ -410,6 +410,16 @@ class Epp::Domain < Domain
)
end
def epp_destroy(frame)
if frame.css('delete').attr('verified').to_s.downcase != 'yes'
registrant_verification_asked!
pending_delete!
true # aka 1001 pending_delete
else
destroy
end
end
### RENEW ###
def renew(cur_exp_date, period, unit = 'y')

View file

@ -0,0 +1,25 @@
Tere,
<br><br>
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %>
<br><br>
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
<br><br>
Taotlus on aktiivne <48> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.<br>
<%= link_to @verification_url, @verification_url %>
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %>
<br><br>
To confirm the update please visit this website, once again review the data and press approve:<br>
<%= link_to @verification_url, @verification_url %>
<br><br>
The application will remain in pending status for <48> hrs and will be automaticcally rejected if it is not approved nor rejected before.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,25 @@
Tere,
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %>
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
Taotlus on aktiivne <48> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.
<%= link_to @verification_url, @verification_url %>
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %>
To confirm the update please visit this website, once again review the data and press approve:
<%= link_to @verification_url, @verification_url %>
The application will remain in pending status for <48> hrs and will be automaticcally rejected if it is not approved nor rejected before.
Best Regards,
Estonian Internet Foundation

View file

@ -21,7 +21,7 @@ Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige
Lugupidamisega
Eesti Interneti SA
---------------------------------------------------------------------------------
--------------------------------------
Hi,

View file

@ -1,9 +0,0 @@
xml.epp_head do
xml.response do
xml.result('code' => '1001') do
xml.msg 'Command completed successfully; action pending'
end
end
xml << render('/epp/shared/trID')
end