mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Prevent domain deleting if status prohibits it
This commit is contained in:
parent
0096968265
commit
b4602e701c
7 changed files with 48 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
class Admin::DomainsController < ApplicationController
|
||||
before_action :set_domain, only: [:show, :edit, :update]
|
||||
before_action :set_domain, only: [:show, :edit, :update, :destroy]
|
||||
before_action :verify_deletion, only: [:destroy]
|
||||
|
||||
def new
|
||||
@domain = Domain.new
|
||||
|
@ -37,6 +38,16 @@ class Admin::DomainsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @domain.destroy
|
||||
flash[:notice] = I18n.t('shared.domain_deleted')
|
||||
redirect_to admin_domains_path
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_delete_domain')
|
||||
redirect_to [:admin, @domain]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
|
@ -46,5 +57,11 @@ class Admin::DomainsController < ApplicationController
|
|||
def domain_params
|
||||
params.require(:domain).permit(:name, :period, :period_unit, :registrar_id, :owner_contact_id)
|
||||
end
|
||||
|
||||
def verify_deletion
|
||||
return if @domain.can_be_deleted?
|
||||
flash[:alert] = I18n.t('shared.domain_status_prohibits_deleting')
|
||||
redirect_to [:admin, @domain]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue