mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
parent
880ce2ed62
commit
e0960bcca4
10 changed files with 54 additions and 85 deletions
39
app/controllers/admin/domains/force_delete_controller.rb
Normal file
39
app/controllers/admin/domains/force_delete_controller.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
module Admin
|
||||
module Domains
|
||||
class ForceDeleteController < BaseController
|
||||
def create
|
||||
authorize! :manage, domain
|
||||
|
||||
domain.transaction do
|
||||
domain.schedule_force_delete
|
||||
domain.registrar.messages.create!(body: t('force_delete_set_on_domain', domain_name: domain.name))
|
||||
|
||||
if notify_by_email?
|
||||
DomainDeleteMailer.forced(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
registrant: domain.registrant,
|
||||
template_name: params[:template_name]).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to edit_admin_domain_url(domain), notice: t('.scheduled')
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize! :manage, domain
|
||||
domain.cancel_force_delete
|
||||
redirect_to edit_admin_domain_url(domain), notice: t('.cancelled')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain
|
||||
@domain ||= Domain.find(params[:domain_id])
|
||||
end
|
||||
|
||||
def notify_by_email?
|
||||
ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:notify_by_email])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -62,34 +62,6 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def schedule_force_delete
|
||||
raise 'Template param cannot be empty' if params[:template_name].blank?
|
||||
|
||||
@domain.transaction do
|
||||
@domain.schedule_force_delete
|
||||
@domain.registrar.messages.create!(body: I18n.t('force_delete_set_on_domain', domain_name: @domain.name))
|
||||
|
||||
if notify_by_email?
|
||||
DomainDeleteMailer.forced(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
registrant: @domain.registrant,
|
||||
template_name: params[:template_name]).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to edit_admin_domain_url(@domain), notice: t('.scheduled')
|
||||
end
|
||||
|
||||
def cancel_force_delete
|
||||
if @domain.cancel_force_delete
|
||||
flash[:notice] = t('.cancelled')
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_domain')
|
||||
end
|
||||
|
||||
redirect_to edit_admin_domain_url(@domain)
|
||||
end
|
||||
|
||||
def versions
|
||||
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
||||
@versions = @domain.versions
|
||||
|
@ -138,9 +110,5 @@ module Admin
|
|||
def force_delete_templates
|
||||
%w(removed_company death)
|
||||
end
|
||||
|
||||
def notify_by_email?
|
||||
ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:notify_by_email])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,8 +49,8 @@ class DomainPresenter
|
|||
)
|
||||
else
|
||||
view.link_to(view.t('admin.domains.force_delete_toggle_btn.cancel'),
|
||||
view.cancel_force_delete_admin_domain_path(domain),
|
||||
method: :patch,
|
||||
view.admin_domain_force_delete_path(domain),
|
||||
method: :delete,
|
||||
data: { confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confim') },
|
||||
class: 'btn btn-primary')
|
||||
end
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<%= form_tag schedule_force_delete_admin_domain_path, method: :patch,
|
||||
id: 'domain-force-delete-form', class: 'form-horizontal' do %>
|
||||
<%= form_tag admin_domain_force_delete_path(domain), id: 'domain-force-delete-form',
|
||||
class: 'form-horizontal' do %>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-9 col-md-offset-2">
|
||||
<div class="checkbox">
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
<hr>
|
||||
|
||||
<%= render 'form' %>
|
||||
<%= render 'force_delete_dialog', templates: force_delete_templates %>
|
||||
<%= render 'force_delete_dialog', domain: @domain, templates: force_delete_templates %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue