mirror of
https://github.com/internetee/registry.git
synced 2025-06-13 16:14:47 +02:00
Merge pull request #2232 from internetee/2218-fd-prohibit-settings-serverdeleteprohibited
ForceDelete prohibit settings serverDeleteProhibited
This commit is contained in:
commit
ee1c7303e1
3 changed files with 37 additions and 2 deletions
|
@ -3,6 +3,7 @@ module Admin
|
||||||
before_action :set_domain, only: %i[show edit update keep]
|
before_action :set_domain, only: %i[show edit update keep]
|
||||||
authorize_resource
|
authorize_resource
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/MethodLength
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
domains = if params[:statuses_contains]
|
domains = if params[:statuses_contains]
|
||||||
|
@ -30,6 +31,7 @@ module Admin
|
||||||
|
|
||||||
render_by_format('admin/domains/index', 'domains')
|
render_by_format('admin/domains/index', 'domains')
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
def show
|
def show
|
||||||
# Validation is needed to warn users
|
# Validation is needed to warn users
|
||||||
|
@ -40,7 +42,9 @@ module Admin
|
||||||
build_associations
|
build_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/MethodLength
|
||||||
def update
|
def update
|
||||||
|
rollback_history = @domain.json_statuses_history&.[]('admin_store_statuses_history')
|
||||||
dp = ignore_empty_statuses
|
dp = ignore_empty_statuses
|
||||||
@domain.is_admin = true
|
@domain.is_admin = true
|
||||||
@domain.admin_status_update dp[:statuses]
|
@domain.admin_status_update dp[:statuses]
|
||||||
|
@ -49,11 +53,14 @@ module Admin
|
||||||
flash[:notice] = I18n.t('domain_updated')
|
flash[:notice] = I18n.t('domain_updated')
|
||||||
redirect_to [:admin, @domain]
|
redirect_to [:admin, @domain]
|
||||||
else
|
else
|
||||||
|
@domain.reload
|
||||||
|
@domain.admin_status_update rollback_history
|
||||||
build_associations
|
build_associations
|
||||||
flash.now[:alert] = "#{I18n.t('failed_to_update_domain')} #{@domain.errors.full_messages.join(', ')}"
|
flash.now[:alert] = "#{I18n.t('failed_to_update_domain')} #{@domain.errors.full_messages.join(', ')}"
|
||||||
render 'edit'
|
render 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
def versions
|
def versions
|
||||||
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
||||||
|
|
|
@ -121,8 +121,8 @@ class Domain < ApplicationRecord
|
||||||
validate :status_is_consistant
|
validate :status_is_consistant
|
||||||
def status_is_consistant
|
def status_is_consistant
|
||||||
has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
||||||
if !has_error && (statuses & DELETE_STATUSES).any?
|
if !has_error && statuses.include?(DomainStatus::PENDING_DELETE)
|
||||||
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED unless locked_by_registrant?
|
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
|
||||||
end
|
end
|
||||||
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
|
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
|
||||||
end
|
end
|
||||||
|
@ -592,6 +592,8 @@ class Domain < ApplicationRecord
|
||||||
def admin_status_update(update)
|
def admin_status_update(update)
|
||||||
update_unless_locked_by_registrant(update)
|
update_unless_locked_by_registrant(update)
|
||||||
update_not_by_locked_statuses(update)
|
update_not_by_locked_statuses(update)
|
||||||
|
return unless update
|
||||||
|
|
||||||
# check for deleted status
|
# check for deleted status
|
||||||
statuses.each do |s|
|
statuses.each do |s|
|
||||||
unless update.include? s
|
unless update.include? s
|
||||||
|
|
|
@ -21,6 +21,32 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
||||||
assert_text 'Force delete procedure has been scheduled'
|
assert_text 'Force delete procedure has been scheduled'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_force_delete_prohibit_adding_deleteprohibited_status
|
||||||
|
refute @domain.force_delete_scheduled?
|
||||||
|
|
||||||
|
visit edit_admin_domain_url(@domain)
|
||||||
|
click_link_or_button 'Force delete domain'
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
|
assert @domain.force_delete_scheduled?
|
||||||
|
assert_current_path edit_admin_domain_path(@domain)
|
||||||
|
assert_text 'Force delete procedure has been scheduled'
|
||||||
|
|
||||||
|
click_link_or_button 'Add new status'
|
||||||
|
last_input = page.all(:id, 'domain_statuses_').last
|
||||||
|
last_input.find(:xpath, 'option[10]').select_option
|
||||||
|
click_link_or_button 'Save'
|
||||||
|
assert_text 'Domain updated!'
|
||||||
|
|
||||||
|
visit edit_admin_domain_url(@domain)
|
||||||
|
click_link_or_button 'Cancel force delete'
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
|
refute @domain.force_delete_scheduled?
|
||||||
|
assert_current_path edit_admin_domain_path(@domain)
|
||||||
|
assert_text 'Force delete procedure has been cancelled'
|
||||||
|
end
|
||||||
|
|
||||||
def test_notifies_registrar
|
def test_notifies_registrar
|
||||||
assert_difference '@domain.registrar.notifications.size' do
|
assert_difference '@domain.registrar.notifications.size' do
|
||||||
visit edit_admin_domain_url(@domain)
|
visit edit_admin_domain_url(@domain)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue