mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Merge branch 'master' into 93-locked-domains-failed-after-fc
This commit is contained in:
commit
ab26100e78
24 changed files with 269 additions and 69 deletions
|
@ -1,7 +1,7 @@
|
|||
module Domain::RegistryLockable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
LOCK_STATUSES = if Feature.obj_and_extensions_statuses_enabled?
|
||||
LOCK_STATUSES = if Feature.enable_lock_domain_with_new_statuses?
|
||||
[DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||
|
@ -11,20 +11,26 @@ module Domain::RegistryLockable
|
|||
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||
end
|
||||
|
||||
def apply_registry_lock
|
||||
EXTENSIONS_STATUS = [DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED].freeze
|
||||
|
||||
def apply_registry_lock(extensions_prohibited:)
|
||||
return unless registry_lockable?
|
||||
return if locked_by_registrant?
|
||||
|
||||
transaction do
|
||||
self.admin_store_statuses_history = self.statuses
|
||||
self.statuses |= LOCK_STATUSES
|
||||
self.locked_by_registrant_at = Time.zone.now
|
||||
alert_registrar_lock_changes!(lock: true)
|
||||
|
||||
save!
|
||||
apply_statuses_locked_statuses(extensions_prohibited: extensions_prohibited)
|
||||
end
|
||||
end
|
||||
|
||||
def apply_statuses_locked_statuses(extensions_prohibited:)
|
||||
self.statuses |= LOCK_STATUSES
|
||||
self.statuses |= EXTENSIONS_STATUS if Feature.obj_and_extensions_statuses_enabled? && extensions_prohibited
|
||||
self.locked_by_registrant_at = Time.zone.now
|
||||
alert_registrar_lock_changes!(lock: true)
|
||||
|
||||
save!
|
||||
end
|
||||
|
||||
def registry_lockable?
|
||||
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
|
||||
|
@ -42,17 +48,23 @@ module Domain::RegistryLockable
|
|||
return unless locked_by_registrant?
|
||||
|
||||
transaction do
|
||||
LOCK_STATUSES.each do |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!
|
||||
remove_statuses_from_locked_domain
|
||||
end
|
||||
end
|
||||
|
||||
def remove_statuses_from_locked_domain
|
||||
LOCK_STATUSES.each do |domain_status|
|
||||
statuses.delete([domain_status])
|
||||
end
|
||||
|
||||
statuses.delete([EXTENSIONS_STATUS]) if statuses.include? EXTENSIONS_STATUS
|
||||
self.locked_by_registrant_at = nil
|
||||
self.statuses = admin_store_statuses_history || []
|
||||
alert_registrar_lock_changes!(lock: false)
|
||||
|
||||
save!
|
||||
end
|
||||
|
||||
def alert_registrar_lock_changes!(lock: true)
|
||||
translation = lock ? 'locked' : 'unlocked'
|
||||
registrar.notifications.create!(
|
||||
|
|
|
@ -4,4 +4,10 @@ class Feature
|
|||
|
||||
ENV['obj_and_extensions_prohibited'] || false
|
||||
end
|
||||
|
||||
def self.enable_lock_domain_with_new_statuses?
|
||||
return false if ENV['enable_lock_domain_with_new_statuses'] == 'false'
|
||||
|
||||
ENV['enable_lock_domain_with_new_statuses'] || false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ class RegistrantUser < User
|
|||
company_register.representation_rights(citizen_personal_code: ident,
|
||||
citizen_country_code: country.alpha3)
|
||||
end
|
||||
|
||||
|
||||
def contacts(representable: true)
|
||||
Contact.registrant_user_contacts(self, representable: representable)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue