Did small refactoring

This commit is contained in:
Sergei Tsõganov 2022-01-12 10:41:56 +02:00
parent 1f4733bdde
commit c83b99b6de
2 changed files with 14 additions and 8 deletions

View file

@ -469,6 +469,7 @@ class Domain < ApplicationRecord
return false unless pending_update? return false unless pending_update?
return false unless registrant_verification_asked? return false unless registrant_verification_asked?
return false unless registrant_verification_token == token return false unless registrant_verification_token == token
true true
end end
@ -476,6 +477,7 @@ class Domain < ApplicationRecord
return false unless pending_delete? return false unless pending_delete?
return false unless registrant_verification_asked? return false unless registrant_verification_asked?
return false unless registrant_verification_token == token return false unless registrant_verification_token == token
true true
end end
@ -492,10 +494,12 @@ class Domain < ApplicationRecord
def pending_delete! def pending_delete!
return true if pending_delete? return true if pending_delete?
self.epp_pending_delete = true # for epp self.epp_pending_delete = true # for epp
# TODO: if this were to ever return true, that would be wrong. EPP would report sucess pending # TODO: if this were to ever return true, that would be wrong. EPP would report sucess pending
return true unless registrant_verification_asked? return true unless registrant_verification_asked?
pending_delete_confirmation! pending_delete_confirmation!
save(validate: false) # should check if this did succeed save(validate: false) # should check if this did succeed
@ -560,6 +564,7 @@ class Domain < ApplicationRecord
def pending_registrant def pending_registrant
return '' if pending_json.blank? return '' if pending_json.blank?
return '' if pending_json['new_registrant_id'].blank? return '' if pending_json['new_registrant_id'].blank?
Registrant.find_by(id: pending_json['new_registrant_id']) Registrant.find_by(id: pending_json['new_registrant_id'])
end end
@ -590,11 +595,12 @@ class Domain < ApplicationRecord
# special handling for admin changing status # special handling for admin changing status
def admin_status_update(update) def admin_status_update(update)
return unless update
PaperTrail.request(enabled: false) do PaperTrail.request(enabled: false) do
update_unless_locked_by_registrant(update) update_unless_locked_by_registrant(update)
update_not_by_locked_statuses(update) update_not_by_locked_statuses(update)
end end
return unless update
# check for deleted status # check for deleted status
statuses.each do |s| statuses.each do |s|
@ -660,7 +666,7 @@ class Domain < ApplicationRecord
end end
def manage_automatic_statuses def manage_automatic_statuses
if !self.class.nameserver_required? unless self.class.nameserver_required?
deactivate if nameservers.reject(&:marked_for_destruction?).empty? deactivate if nameservers.reject(&:marked_for_destruction?).empty?
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
end end