implement mechanism of save statuses for force delete and lock

This commit is contained in:
Oleg Hasjanov 2021-07-14 11:16:56 +03:00
parent ec90722bf0
commit 96bc237484
9 changed files with 142 additions and 23 deletions

View file

@ -1,6 +1,10 @@
module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
module Domain::ForceDelete
extend ActiveSupport::Concern
FORCE_DELETE_STATUSES = [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
included do
store_accessor :force_delete_data,
:force_delete_type,

View file

@ -36,9 +36,10 @@ module Domain::RegistryLockable
transaction do
LOCK_STATUSES.each do |domain_status|
statuses.delete(domain_status)
statuses.delete([domain_status])
end
self.locked_by_registrant_at = nil
self.statuses = admin_store_statuses_history || []
alert_registrar_lock_changes!(lock: false)
save!

View file

@ -553,8 +553,22 @@ class Domain < ApplicationRecord
statuses.include?(DomainStatus::FORCE_DELETE)
end
def update_unless_locked_by_registrant(update)
update(admin_store_statuses_history: update) unless locked_by_registrant?
end
def update_not_by_locked_statuses(update)
return unless locked_by_registrant?
result = update.reject { |status| RegistryLockable::LOCK_STATUSES.include? status }
update(admin_store_statuses_history: result)
end
# special handling for admin changing status
def admin_status_update(update)
update_unless_locked_by_registrant(update)
update_not_by_locked_statuses(update)
# check for deleted status
statuses.each do |s|
unless update.include? s