Admin pendings refactored, added delete pending managament #2785

This commit is contained in:
Priit Tark 2015-08-12 00:40:41 +03:00
parent 07e4c0cd96
commit 714a36f34c
11 changed files with 62 additions and 46 deletions

View file

@ -10,7 +10,6 @@ class Admin::DomainVersionsController < AdminController
frame = Nokogiri::XML(@domain.pending_json['frame'])
@pending_user = User.find(@domain.pending_json['current_user_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)
end
end

View 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

View file

@ -1,4 +1,4 @@
class Admin::PendingsController < AdminController
class Admin::PendingUpdatesController < AdminController
before_action :find_domain
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
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
redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure)
end
@ -17,7 +17,7 @@ class Admin::PendingsController < AdminController
authorize! :destroy, :pending
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
redirect_to admin_domain_path(@domain.id), alert: t(:failure)
end