mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Admin pendings refactored, added delete pending managament #2785
This commit is contained in:
parent
07e4c0cd96
commit
714a36f34c
11 changed files with 62 additions and 46 deletions
|
@ -10,7 +10,6 @@ class Admin::DomainVersionsController < AdminController
|
||||||
frame = Nokogiri::XML(@domain.pending_json['frame'])
|
frame = Nokogiri::XML(@domain.pending_json['frame'])
|
||||||
@pending_user = User.find(@domain.pending_json['current_user_id'])
|
@pending_user = User.find(@domain.pending_json['current_user_id'])
|
||||||
@pending_domain = Epp::Domain.find(@domain.id)
|
@pending_domain = Epp::Domain.find(@domain.id)
|
||||||
@pending_domain.updated_at = @domain.pending_json['domain']['updated_at'].last
|
|
||||||
@pending_domain.update(frame, @pending_user, false)
|
@pending_domain.update(frame, @pending_user, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
35
app/controllers/admin/pending_deletes_controller.rb
Normal file
35
app/controllers/admin/pending_deletes_controller.rb
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
class Admin::PendingDeletesController < AdminController
|
||||||
|
before_action :find_domain
|
||||||
|
before_action :check_status
|
||||||
|
|
||||||
|
def update
|
||||||
|
authorize! :update, :pending
|
||||||
|
|
||||||
|
@epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending
|
||||||
|
if @epp_domain.apply_pending_delete!
|
||||||
|
redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied)
|
||||||
|
else
|
||||||
|
redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
authorize! :destroy, :pending
|
||||||
|
|
||||||
|
if @domain.clean_pendings!
|
||||||
|
redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed)
|
||||||
|
else
|
||||||
|
redirect_to admin_domain_path(@domain.id), alert: t(:failure)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_domain
|
||||||
|
@domain = Domain.find(params[:domain_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_status
|
||||||
|
return redirect_to admin_domain_path(@domain.id), alert: t(:something_wrong) unless @domain.pending_delete?
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
class Admin::PendingsController < AdminController
|
class Admin::PendingUpdatesController < AdminController
|
||||||
before_action :find_domain
|
before_action :find_domain
|
||||||
before_action :check_status
|
before_action :check_status
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class Admin::PendingsController < AdminController
|
||||||
|
|
||||||
@epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending
|
@epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending
|
||||||
if @epp_domain.apply_pending_update!
|
if @epp_domain.apply_pending_update!
|
||||||
redirect_to admin_domain_path(@domain.id), notice: t(:successfully_updated)
|
redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied)
|
||||||
else
|
else
|
||||||
redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure)
|
redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure)
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ class Admin::PendingsController < AdminController
|
||||||
authorize! :destroy, :pending
|
authorize! :destroy, :pending
|
||||||
|
|
||||||
if @domain.clean_pendings!
|
if @domain.clean_pendings!
|
||||||
redirect_to admin_domain_path(@domain.id), notice: t(:successfully_destroyed)
|
redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed)
|
||||||
else
|
else
|
||||||
redirect_to admin_domain_path(@domain.id), alert: t(:failure)
|
redirect_to admin_domain_path(@domain.id), alert: t(:failure)
|
||||||
end
|
end
|
|
@ -31,14 +31,6 @@
|
||||||
%br
|
%br
|
||||||
= creator
|
= creator
|
||||||
|
|
||||||
%td
|
|
||||||
%p
|
|
||||||
= "#{domain.period}#{domain.period_unit}"
|
|
||||||
%br
|
|
||||||
= "#{l(domain.valid_from, format: :date)}"
|
|
||||||
%br
|
|
||||||
= "#{l(domain.valid_to, format: :date)}"
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
%p
|
%p
|
||||||
- domain.statuses.each do |s|
|
- domain.statuses.each do |s|
|
||||||
|
@ -52,6 +44,14 @@
|
||||||
%p
|
%p
|
||||||
= link_to t(:pending_epp), '#', class: 'js-pending-toggle'
|
= link_to t(:pending_epp), '#', class: 'js-pending-toggle'
|
||||||
|
|
||||||
|
%td
|
||||||
|
%p
|
||||||
|
= "#{domain.period}#{domain.period_unit}"
|
||||||
|
%br
|
||||||
|
= "#{l(domain.valid_from, format: :date)}"
|
||||||
|
%br
|
||||||
|
= "#{l(domain.valid_to, format: :date)}"
|
||||||
|
|
||||||
%td
|
%td
|
||||||
- registrant.each do |r|
|
- registrant.each do |r|
|
||||||
%p
|
%p
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th{class: 'col-xs-1'}= t(:timestap)
|
%th{class: 'col-xs-1'}= t(:timestap)
|
||||||
%th{class: 'col-xs-1'}= t(:period)
|
|
||||||
%th{class: 'col-xs-2'}= t(:statuses)
|
%th{class: 'col-xs-2'}= t(:statuses)
|
||||||
|
%th{class: 'col-xs-1'}= t(:period)
|
||||||
%th{class: 'col-xs-2'}= t(:registrant)
|
%th{class: 'col-xs-2'}= t(:registrant)
|
||||||
%th{class: 'col-xs-2'}= t(:admin)
|
%th{class: 'col-xs-2'}= t(:admin)
|
||||||
%th{class: 'col-xs-2'}= t(:tech)
|
%th{class: 'col-xs-2'}= t(:tech)
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
-# .row
|
|
||||||
-# .col-sm-12
|
|
||||||
-# %h2.text-center-xs= t(:domains)
|
|
||||||
-# %hr
|
|
||||||
-# .row
|
|
||||||
-# .col-md-12
|
|
||||||
-# .table-responsive
|
|
||||||
-# %table.table.table-hover.table-bordered.table-condensed
|
|
||||||
-# %thead
|
|
||||||
-# %tr
|
|
||||||
-# %th{class: 'col-xs-1'}
|
|
||||||
-# = t(:name)
|
|
||||||
-# %th{class: 'col-xs-1'}
|
|
||||||
-# = sort_link(@q, 'whodunnit')
|
|
||||||
-# %th{class: 'col-xs-1'}
|
|
||||||
-# = sort_link(@q, 'created_at')
|
|
||||||
|
|
||||||
-# %tbody
|
|
||||||
-# - @domains.each do |domain|
|
|
||||||
-# - obj = domain.reify
|
|
||||||
-# %tr
|
|
||||||
-# %td= link_to(obj.name, admin_domain_version_path(obj))
|
|
||||||
-# %td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
|
|
||||||
-# %td= l(obj.created_at, format: :short)
|
|
||||||
|
|
||||||
-# .row
|
|
||||||
-# .col-md-12
|
|
||||||
-# = paginate @domains
|
|
8
app/views/admin/domains/form/_pending_delete.haml
Normal file
8
app/views/admin/domains/form/_pending_delete.haml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- if (status == DomainStatus::PENDING_DELETE && f.object.pending_json.present?)
|
||||||
|
= link_to(t(:apply_pending), admin_domain_pending_delete_path(f.object.id, f.object.id),
|
||||||
|
method: :patch, data: { confirm: t(:are_you_sure) },
|
||||||
|
class: 'btn btn-danger btn-xs')
|
||||||
|
|
||||||
|
= link_to(t(:delete_pending), admin_domain_pending_delete_path(f.object.id, f.object.id),
|
||||||
|
method: :delete, data: { confirm: t(:are_you_sure) },
|
||||||
|
class: 'btn btn-danger btn-xs')
|
|
@ -1,8 +1,8 @@
|
||||||
- if (status == DomainStatus::PENDING_UPDATE && f.object.pending_json.present?)
|
- if (status == DomainStatus::PENDING_UPDATE && f.object.pending_json.present?)
|
||||||
= link_to(t(:apply_pending), admin_domain_pending_path(f.object.id, f.object.id),
|
= link_to(t(:apply_pending), admin_domain_pending_update_path(f.object.id, f.object.id),
|
||||||
method: :patch, data: { confirm: t(:are_you_sure) },
|
method: :patch, data: { confirm: t(:are_you_sure) },
|
||||||
class: 'btn btn-danger btn-xs')
|
class: 'btn btn-danger btn-xs')
|
||||||
|
|
||||||
= link_to(t(:delete_pending), admin_domain_pending_path(f.object.id, f.object.id),
|
= link_to(t(:delete_pending), admin_domain_pending_update_path(f.object.id, f.object.id),
|
||||||
method: :delete, data: { confirm: t(:are_you_sure) },
|
method: :delete, data: { confirm: t(:are_you_sure) },
|
||||||
class: 'btn btn-danger btn-xs')
|
class: 'btn btn-danger btn-xs')
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
.pull-right
|
.pull-right
|
||||||
- if model == 'domain'
|
- if model == 'domain'
|
||||||
= render 'admin/domains/form/pending_update', f: f, status: s
|
= render 'admin/domains/form/pending_update', f: f, status: s
|
||||||
|
= render 'admin/domains/form/pending_delete', f: f, status: s
|
||||||
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs js-destroy-status', style: delete_style)
|
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs js-destroy-status', style: delete_style)
|
||||||
.panel-body
|
.panel-body
|
||||||
.form-group
|
.form-group
|
||||||
|
|
|
@ -655,8 +655,8 @@ en:
|
||||||
general: General
|
general: General
|
||||||
id_card: 'ID Card'
|
id_card: 'ID Card'
|
||||||
m_id: 'M-ID'
|
m_id: 'M-ID'
|
||||||
successfully_destroyed: It was successfully deleted.
|
pending_removed: Pending was successfully removed.
|
||||||
successfully_updated: It was successfully updated.
|
pending_applied: Pending was successfully applied.
|
||||||
something_wrong: Not success, something went wrong!
|
something_wrong: Not success, something went wrong!
|
||||||
failure: Not success
|
failure: Not success
|
||||||
not_found: Not found
|
not_found: Not found
|
||||||
|
|
|
@ -184,7 +184,8 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :domains do
|
resources :domains do
|
||||||
resources :domain_versions
|
resources :domain_versions
|
||||||
resources :pendings
|
resources :pending_updates
|
||||||
|
resources :pending_deletes
|
||||||
member do
|
member do
|
||||||
post 'set_force_delete'
|
post 'set_force_delete'
|
||||||
post 'unset_force_delete'
|
post 'unset_force_delete'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue