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

@ -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