clear unnecessary code in structure, refactored formatted code

This commit is contained in:
Oleg Hasjanov 2021-04-05 16:14:32 +03:00
parent 28a54d6612
commit 9bfdb0fb39
3 changed files with 700 additions and 403 deletions

View file

@ -1,8 +1,6 @@
module Domain::RegistryLockable module Domain::RegistryLockable
extend ActiveSupport::Concern extend ActiveSupport::Concern
# status_notes public.hstore,
LOCK_STATUSES = [DomainStatus::SERVER_UPDATE_PROHIBITED, LOCK_STATUSES = [DomainStatus::SERVER_UPDATE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
@ -11,11 +9,7 @@ module Domain::RegistryLockable
return unless registry_lockable? return unless registry_lockable?
return if locked_by_registrant? return if locked_by_registrant?
self.locked_domain_statuses_history = self.statuses.map do |status| put_statuses_to_json_history_before_locked
if LOCK_STATUSES.include? status
status
end
end
transaction do transaction do
self.statuses |= LOCK_STATUSES self.statuses |= LOCK_STATUSES
@ -44,9 +38,7 @@ module Domain::RegistryLockable
transaction do transaction do
LOCK_STATUSES.each do |domain_status| LOCK_STATUSES.each do |domain_status|
unless self.locked_domain_statuses_history.include? domain_status delete_domain_statuses_which_not_declared_before domain_status
statuses.delete(domain_status)
end
end end
self.locked_by_registrant_at = nil self.locked_by_registrant_at = nil
alert_registrar_lock_changes!(lock: false) alert_registrar_lock_changes!(lock: false)
@ -64,4 +56,16 @@ module Domain::RegistryLockable
attached_obj_type: self.class.name attached_obj_type: self.class.name
) )
end end
private
def put_statuses_to_json_history_before_locked
self.locked_domain_statuses_history = statuses.map do |status|
status if LOCK_STATUSES.include? status
end
end
def delete_domain_statuses_which_not_declared_before(domain_status)
statuses.delete(domain_status) unless locked_domain_statuses_history.include? domain_status
end
end end

View file

@ -16,8 +16,9 @@ class Domain < ApplicationRecord
attr_accessor :legal_document_id attr_accessor :legal_document_id
# serialize :json_statuses_history, HashSerializer store_accessor :json_statuses_history,
store_accessor :json_statuses_history, :force_delete_domain_statuses_history, :locked_domain_statuses_history :force_delete_domain_statuses_history,
:locked_domain_statuses_history
alias_attribute :on_hold_time, :outzone_at alias_attribute :on_hold_time, :outzone_at
alias_attribute :outzone_time, :outzone_at alias_attribute :outzone_time, :outzone_at

File diff suppressed because it is too large Load diff