Registrant change confirmation logic

This commit is contained in:
Priit Tark 2015-05-13 10:00:52 +03:00
parent 762054e5f1
commit 6c47124a28
15 changed files with 292 additions and 17 deletions

View file

@ -34,7 +34,11 @@ class Epp::DomainsController < EppController
authorize! :update, @domain, @password
if @domain.update(params[:parsed_frame], current_user)
render_epp_response '/epp/domains/success'
if @domain.pending_update?
render_epp_response '/epp/domains/success_pending'
else
render_epp_response '/epp/domains/success'
end
else
handle_errors(@domain)
end

View file

@ -0,0 +1,13 @@
class DomainMailer < ApplicationMailer
def registrant_updated(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
@old_registrant = Registrant.find(domain.registrant_id_was)
@domain = domain
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_registrant_update_subject, name: @domain.name)} [#{@domain.name}]")
end
end

View file

@ -1,6 +1,6 @@
class InvoiceMailer < ApplicationMailer
def invoice_email(invoice, pdf)
return if Rails.env.production? ? false : TEST_EMAILS.include?(invoice.billing_email)
return if Rails.env.production? ? false : !TEST_EMAILS.include?(invoice.billing_email)
@invoice = invoice
attachments[invoice.pdf_name] = pdf

View file

@ -40,14 +40,28 @@ class Domain < ActiveRecord::Base
has_many :legal_documents, as: :documentable
accepts_nested_attributes_for :legal_documents, reject_if: proc { |attrs| attrs[:body].blank? }
delegate :code, to: :registrant, prefix: true
delegate :email, to: :registrant, prefix: true
delegate :ident, to: :registrant, prefix: true
delegate :phone, to: :registrant, prefix: true
delegate :name, to: :registrar, prefix: true
delegate :name, to: :registrant, prefix: true
delegate :code, to: :registrant, prefix: true
delegate :ident, to: :registrant, prefix: true
delegate :email, to: :registrant, prefix: true
delegate :phone, to: :registrant, prefix: true
delegate :street, to: :registrant, prefix: true
delegate :city, to: :registrant, prefix: true
delegate :zip, to: :registrant, prefix: true
delegate :state, to: :registrant, prefix: true
delegate :country, to: :registrant, prefix: true
delegate :name, to: :registrar, prefix: true
delegate :street, to: :registrar, prefix: true
before_create :generate_auth_info
before_create :set_validity_dates
before_update :manage_statuses
def manage_statuses
return unless registrant_id_changed?
domain_statuses.build(value: DomainStatus::PENDING_UPDATE) if registrant_verification_asked_at.present?
end
before_save :touch_always_version
def touch_always_version
self.updated_at = Time.zone.now
@ -103,7 +117,7 @@ class Domain < ActiveRecord::Base
validate :validate_nameserver_ips
attr_accessor :registrant_typeahead, :update_me
attr_accessor :registrant_typeahead, :update_me, :deliver_emails
def subordinate_nameservers
nameservers.select { |x| x.hostname.end_with?(name) }
@ -154,6 +168,13 @@ class Domain < ActiveRecord::Base
)).empty?
end
def pending_update?
(domain_statuses.pluck(:value) & %W(
#{DomainStatus::PENDING_UPDATE}
)).present?
end
alias_method :update_pending?, :pending_update?
### VALIDATIONS ###
def validate_nameserver_ips
@ -230,8 +251,6 @@ class Domain < ActiveRecord::Base
# otherwise domain_statuses are in old state for domain object
domain_statuses.reload
# contacts.includes(:address).each(&:manage_statuses)
end
def children_log

View file

@ -2,6 +2,13 @@
class Epp::Domain < Domain
include EppErrors
before_update :manage_permissions
def manage_permissions
return unless update_pending?
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
false
end
class << self
def new_from_epp(frame, current_user)
domain = Epp::Domain.new
@ -88,6 +95,8 @@ class Epp::Domain < Domain
regt = Registrant.find_by(code: code)
if regt
at[:registrant_id] = regt.id
delivery_date = frame.css('registrant').attr('verified').to_s.downcase == 'yes' ? nil : Time.zone.now
at[:registrant_verification_asked_at] = delivery_date
else
add_epp_error('2303', 'registrant', code, [:registrant, :not_found])
end
@ -115,7 +124,6 @@ class Epp::Domain < Domain
at[:dnskeys_attributes] = dnskeys_attrs(dnskey_frame, action)
at[:legal_documents_attributes] = legal_document_from(frame)
at
end
# rubocop: enable Metrics/PerceivedComplexity
@ -386,6 +394,7 @@ class Epp::Domain < Domain
at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes]
at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes]
self.deliver_emails = true # turn on email delivery for epp
errors.empty? && super(at)
end

View file

@ -22,7 +22,7 @@ Tänav: <%= @contact.street %><br>
Linn: <%= @contact.city %><br>
Riik: <%= @contact.country %>
<br><br>
Lugupidamisega
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
@ -49,5 +49,5 @@ Street: <%= @contact.street %><br>
City: <%= @contact.city %><br>
Country: <%= @contact.country %>
<br><br>
Best Regards,
Best Regards,<br>
Eesti Interneti SA

View file

@ -0,0 +1,47 @@
Tere,
<br><br>
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %>
<br><br>
Uued registreerija andmed:<br>
Nimi: <%= @domain.registrant_name %><br>
<% if @domain.registrant.priv? %>
Isikukood: <%= @domain.registrant_ident %><br>
<% else %>
Äriregistrikood: <%= @domain.registrant_ident %><br>
<% end %>
Epost: <%= @domain.registrant_email %><br>
Tel: <%= @domain.registrant_phone %><br>
Tänav: <%= @domain.registrant_street %><br>
Linn: <%= @domain.registrant_city %><br>
Riik: <%= @domain.registrant_country %>
<br><br>
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:<br>
https://testrar.internet.ee/app/owpieruaofaksj298317498324rquhetoiqhepoijfqperyfq9384yuqpohewg
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %>
<br><br>
New registrant:<br>
Name: <%= @domain.registrant_name %><br>
<% if @domain.registrant.priv? %>
Personal code: <%= @domain.registrant_ident %><br>
<% else %>
Business Registry code: <%= @domain.registrant_ident %><br>
<% end %>
E-mail: <%= @domain.registrant_email %><br>
Tel: <%= @domain.registrant_phone %><br>
Street: <%= @domain.registrant_street %><br>
City: <%= @domain.registrant_city %><br>
Country: <%= @domain.registrant_country %>
<br><br>
To confirm the update please visit this website, once again review the data and press approve:<br>
https://testrar.internet.ee/app/owpieruaofaksj298317498324rquhetoiqhepoijfqperyfq9384yuqpohewg
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,47 @@
Tere,
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %>
Uued registreerija andmed:
Nimi: <%= @domain.registrant_name %>
<% if @domain.registrant.priv? %>
Isikukood: <%= @domain.registrant_ident %>
<% else %>
Äriregistrikood: <%= @domain.registrant_ident %>
<% end %>
Epost: <%= @domain.registrant_email %>
Tel: <%= @domain.registrant_phone %>
Tänav: <%= @domain.registrant_street %>
Linn: <%= @domain.registrant_city %>
Riik: <%= @domain.registrant_country %>
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
https://testrar.internet.ee/app/owpieruaofaksj298317498324rquhetoiqhepoijfqperyfq9384yuqpohewg
Lugupidamisega
Eesti Interneti SA
---------------------------------------------------------------------------------
Hi,
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %>
New registrant:
Name: <%= @domain.registrant_name %>
<% if @domain.registrant.priv? %>
Personal code: <%= @domain.registrant_ident %>
<% else %>
Business Registry code: <%= @domain.registrant_ident %>
<% end %>
E-mail: <%= @domain.registrant_email %>
Tel: <%= @domain.registrant_phone %>
Street: <%= @domain.registrant_street %>
City: <%= @domain.registrant_city %>
Country: <%= @domain.registrant_country %>
To confirm the update please visit this website, once again review the data and press approve:
https://testrar.internet.ee/app/owpieruaofaksj298317498324rquhetoiqhepoijfqperyfq9384yuqpohewg
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,9 @@
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