mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
Further massage rubocop issues
This commit is contained in:
parent
9d7dc59652
commit
322d931856
7 changed files with 65 additions and 63 deletions
|
@ -5,11 +5,9 @@ module Admin
|
||||||
set_domain
|
set_domain
|
||||||
authorize! :manage, @domain
|
authorize! :manage, @domain
|
||||||
if @domain.remove_registry_lock
|
if @domain.remove_registry_lock
|
||||||
redirect_to edit_admin_domain_url(@domain),
|
redirect_to edit_admin_domain_url(@domain), notice: t('.success')
|
||||||
notice: t('admin.domains.registry_lock_delete.success')
|
|
||||||
else
|
else
|
||||||
redirect_to edit_admin_domain_url(@domain),
|
redirect_to edit_admin_domain_url(@domain), alert: t('.error')
|
||||||
alert: t('admin.domains.registry_lock_delete.error')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
module Concerns::Domain::Lockable
|
|
||||||
extend ActiveSupport::Concern
|
|
||||||
|
|
||||||
def apply_registry_lock
|
|
||||||
return unless registry_lockable?
|
|
||||||
return if locked_by_registrant?
|
|
||||||
|
|
||||||
transaction do
|
|
||||||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
|
||||||
statuses << DomainStatus::SERVER_DELETE_PROHIBITED
|
|
||||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
|
||||||
self.locked_by_registrant_at = Time.zone.now
|
|
||||||
save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def registry_lockable?
|
|
||||||
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
|
|
||||||
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
|
|
||||||
DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
|
|
||||||
DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE
|
|
||||||
]).empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def locked_by_registrant?
|
|
||||||
return false unless locked_by_registrant_at
|
|
||||||
|
|
||||||
lock_statuses = [
|
|
||||||
DomainStatus::SERVER_UPDATE_PROHIBITED,
|
|
||||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
|
||||||
DomainStatus::SERVER_TRANSFER_PROHIBITED,
|
|
||||||
]
|
|
||||||
|
|
||||||
(statuses & lock_statuses).count == 3
|
|
||||||
end
|
|
||||||
|
|
||||||
def remove_registry_lock
|
|
||||||
return unless locked_by_registrant?
|
|
||||||
|
|
||||||
transaction do
|
|
||||||
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
|
|
||||||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
|
||||||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
|
||||||
self.locked_by_registrant_at = nil
|
|
||||||
|
|
||||||
save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
53
app/models/concerns/domain/registry_lockable.rb
Normal file
53
app/models/concerns/domain/registry_lockable.rb
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
module Concerns
|
||||||
|
module Domain
|
||||||
|
module RegistryLockable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def apply_registry_lock
|
||||||
|
return unless registry_lockable?
|
||||||
|
return if locked_by_registrant?
|
||||||
|
|
||||||
|
transaction do
|
||||||
|
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||||
|
statuses << DomainStatus::SERVER_DELETE_PROHIBITED
|
||||||
|
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||||
|
self.locked_by_registrant_at = Time.zone.now
|
||||||
|
save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def registry_lockable?
|
||||||
|
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||||
|
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
|
||||||
|
DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
|
||||||
|
DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE
|
||||||
|
]).empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def locked_by_registrant?
|
||||||
|
return false unless locked_by_registrant_at
|
||||||
|
|
||||||
|
lock_statuses = [
|
||||||
|
DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_TRANSFER_PROHIBITED,
|
||||||
|
]
|
||||||
|
|
||||||
|
(statuses & lock_statuses).count == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_registry_lock
|
||||||
|
return unless locked_by_registrant?
|
||||||
|
|
||||||
|
transaction do
|
||||||
|
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
|
||||||
|
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||||
|
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
||||||
|
self.locked_by_registrant_at = nil
|
||||||
|
|
||||||
|
save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,7 +6,7 @@ class Domain < ActiveRecord::Base
|
||||||
include Concerns::Domain::ForceDelete
|
include Concerns::Domain::ForceDelete
|
||||||
include Concerns::Domain::Deletable
|
include Concerns::Domain::Deletable
|
||||||
include Concerns::Domain::Transferable
|
include Concerns::Domain::Transferable
|
||||||
include Concerns::Domain::Lockable
|
include Concerns::Domain::RegistryLockable
|
||||||
|
|
||||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,10 @@ class DomainPresenter
|
||||||
|
|
||||||
def remove_registry_lock_btn
|
def remove_registry_lock_btn
|
||||||
return unless domain.locked_by_registrant?
|
return unless domain.locked_by_registrant?
|
||||||
view.link_to(view.t('admin.domains.registry_lock_delete.btn'),
|
view.link_to(view.t('admin.domains.registry_lock.destroy.btn'),
|
||||||
view.admin_domain_registry_lock_path(domain),
|
view.admin_domain_registry_lock_path(domain),
|
||||||
method: :delete,
|
method: :delete,
|
||||||
data: { confirm: view.t('admin.domains.registry_lock_delete.confirm') },
|
data: { confirm: view.t('admin.domains.registry_lock.destroy.confirm') },
|
||||||
class: 'dropdown-item')
|
class: 'dropdown-item')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,12 @@ en:
|
||||||
close_btn: Close dialog
|
close_btn: Close dialog
|
||||||
submit_btn: Force delete domain
|
submit_btn: Force delete domain
|
||||||
|
|
||||||
registry_lock_delete:
|
registry_lock:
|
||||||
btn: Remove registry lock
|
destroy:
|
||||||
banner: Domain has a registry lock set by registrant.
|
btn: Remove registry lock
|
||||||
confirm: Are you sure you want to remove the registry lock?
|
confirm: Are you sure you want to remove the registry lock?
|
||||||
success: Registry lock removed
|
success: Registry lock removed
|
||||||
error: Registry lock could not be removed
|
error: Registry lock could not be removed
|
||||||
|
|
||||||
versions:
|
versions:
|
||||||
time: Time
|
time: Time
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class DomainLockableTest < ActiveSupport::TestCase
|
class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue