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

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