Pending history and admin controls #2557

This commit is contained in:
Priit Tark 2015-08-12 00:13:42 +03:00
parent 6986b7b738
commit 07e4c0cd96
10 changed files with 95 additions and 84 deletions

View file

@ -0,0 +1,35 @@
class Admin::PendingsController < 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_update!
redirect_to admin_domain_path(@domain.id), notice: t(:successfully_updated)
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(:successfully_destroyed)
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_update?
end
end

View file

@ -123,7 +123,8 @@ class Ability
can :manage, WhiteIp
can :read, ApiLog::EppLog
can :read, ApiLog::ReppLog
# can :index, :delayed_job
can :update, :pending
can :destroy, :pending
can :create, :zonefile
can :access, :settings_menu
end

View file

@ -367,6 +367,8 @@ class Domain < ActiveRecord::Base
self.pending_json = {}
statuses.delete(DomainStatus::PENDING_UPDATE)
statuses.delete(DomainStatus::PENDING_DELETE)
status_notes[DomainStatus::PENDING_UPDATE] = ''
status_notes[DomainStatus::PENDING_DELETE] = ''
save
end

View file

@ -433,9 +433,10 @@ class Epp::Domain < Domain
return unless update(frame, user, false)
clean_pendings!
self.deliver_emails = true # turn on email delivery for epp
self.deliver_emails = true # turn on email delivery
DomainMailer.registrant_updated_notification_for_new_registrant(self).deliver_now
old_registrant_email.deliver_now
true
end
def apply_pending_delete!
@ -446,6 +447,7 @@ class Epp::Domain < Domain
DomainMailer.delete_confirmation(self).deliver_now
clean_pendings! if epp_destroy(frame, user, false)
true
end
def attach_legal_document(legal_document_data)

View file

@ -1,3 +1,4 @@
- statuses_link ||= false
- version ||= false
- domain ||= false
- pending_user ||= false
@ -11,30 +12,24 @@
- registrant = children[:registrant] || []
- event = version.event
- creator = plain_username(version.terminator)
- elsif pending_user # pending history
- else # pending history
- nameservers = domain.nameservers
- tech_contacts = domain.tech_contacts
- admin_contacts = domain.admin_contacts
- registrant = [domain.registrant]
- creator = pending_user.try(:username)
- event = 'PENDING'
- else # if legacy data not presentable
- nameservers = []
- tech_contacts = []
- admin_contacts = []
- registrant = []
- event = 'Log data is not viewable'
- creator = ''
- event = 'pending'
%td
%p.nowrap
= l(domain.updated_at, format: :short)
= l(domain.updated_at, format: :shorts)
- if statuses_link
%br= link_to t(:edit_statuses), edit_admin_domain_path(params[:domain_id])
%p.text-right
= event
%br
= creator
- if event == 'PENDING'
%br= link_to t(:manage), edit_admin_domain_path(params[:domain_id])
%td
%p
@ -48,7 +43,14 @@
%p
- domain.statuses.each do |s|
= s
- notes = domain.status_notes[s]
- if notes
%br
%i= notes
%br
- if domain.pending_json.present?
%p
= link_to t(:pending_epp), '#', class: 'js-pending-toggle'
%td
- registrant.each do |r|
@ -89,69 +91,13 @@
%p
= domain.registrar.name
-# %td
-# = version.children.inspect
-# %td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:domain]
-# %p{:style => "font-size:x-small;"}
-# = children[:domain][:period]
-# = children[:domain][:period_unit] if children[:domain][:period]
-# - if children[:domain][:valid_to] && children[:domain][:valid_from]
-# = ","
-# = l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
-# - if children[:domain].try(:[], :registrar_id)
-# = ","
-# = Registrar.find(children[:domain][:registrar_id]).try(:name)
-# - if children[:domain][:status]
-# = ',' + children[:domain][:status]
-# %td{ class: changes.include?(:registrant) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:registrant]
-# %p{:style => "font-size:x-small;"}
-# = children[:registrant][:name]
-# = ","
-# = children[:registrant][:phone]
-# = ","
-# = children[:registrant][:email]
-# = ","
-# = children[:registrant][:code]
-# %td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:admin_contacts]
-# - children[:admin_contacts].each do |ac|
-# %p{:style => "font-size:x-small;"}
-# = ac[:name]
-# = ","
-# = ac[:phone]
-# = ","
-# = ac[:email]
-# = ","
-# = ac[:code]
-# %td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:tech_contacts]
-# - children[:tech_contacts].each do |tc|
-# %p{:style => "font-size:x-small;"}
-# = tc[:name]
-# = ","
-# = tc[:phone]
-# = ","
-# = tc[:email]
-# = ","
-# = tc[:code]
-# %td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:nameservers]
-# - children[:nameservers].each do |ns|
-# %p{:style => "font-size:x-small;"}
-# = ns[:hostname]
-# = ","
-# = ns[:ipv4] || ns[:ipv6]
-# %td
-# %p{ :style => 'font-size:x-small;' }
-# = l(version.created_at, format: :short)
-# = whodunnit_with_protocol(version.whodunnit)
-# = version.event
- if domain.pending_json.present?
%tr.js-pending{ style: 'display: none;' }
%td{colspan: 8}
= preserve do
%pre
- formatted_req = Nokogiri::XML(domain.pending_json['frame'])
- if formatted_req.errors.none?
= formatted_req
- else
= domain.pending_json['frame']

View file

@ -11,7 +11,7 @@
%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(:owner)
%th{class: 'col-xs-2'}= t(:registrant)
%th{class: 'col-xs-2'}= t(:admin)
%th{class: 'col-xs-2'}= t(:tech)
%th{class: 'col-xs-2'}= t(:nameservers)
@ -21,14 +21,24 @@
- if @pending_domain.present?
%tr.small
= render 'admin/domain_versions/version',
domain: @pending_domain, pending_user: @pending_user
domain: @pending_domain, pending_user: @pending_user, statuses_link: true
-# current version
- if @domain.versions.present?
%tr.small
= render 'admin/domain_versions/version',
domain: @domain, version: @domain.versions.last
-# all other older versions
- @domain.versions.not_creates.reverse.each do |version|
%tr.small
= render 'admin/domain_versions/version',
domain: version.reify, version: version.previous
:coffee
$(document).on 'click', '.js-pending-toggle', (e) ->
e.preventDefault()
$(document).on 'mousedown', '.js-pending-toggle', (e) ->
target = $(e.target)
target.parents('tr').next('tr.js-pending').toggle()

View file

@ -1 +1,8 @@
yeah
- 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),
method: :patch, data: { confirm: t(:are_you_sure) },
class: 'btn btn-danger btn-xs')
= link_to(t(:delete_pending), admin_domain_pending_path(f.object.id, f.object.id),
method: :delete, data: { confirm: t(:are_you_sure) },
class: 'btn btn-danger btn-xs')

View file

@ -8,6 +8,8 @@
.panel-heading.clearfix
.pull-left= t(:status)
.pull-right
- if model == 'domain'
= render 'admin/domains/form/pending_update', f: f, status: s
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs js-destroy-status', style: delete_style)
.panel-body
.form-group

View file

@ -22,6 +22,7 @@ en:
longer: "%a, %e. %b %Y, %H:%M"
long: "%A, %e. %B %Y, %H:%M"
short: "%d.%m.%y, %H:%M"
shorts: "%d.%m.%y, %H:%M:%S"
date: "%d.%m.%y"
date_long: "%d. %B %Y"
ydate: "%Y.%m.%d"
@ -654,7 +655,10 @@ en:
general: General
id_card: 'ID Card'
m_id: 'M-ID'
destroyed: It was successfully deleted.
successfully_destroyed: It was successfully deleted.
successfully_updated: It was successfully updated.
something_wrong: Not success, something went wrong!
failure: Not success
not_found: Not found
no_connection_to_registry: Connection issue to the registry EPP or REPP server! Please try again later.
domain_not_found: 'Domain was not found'
@ -904,4 +908,5 @@ en:
poll_pending_delete_rejected_by_registrant: 'Registrant rejected domain deletion'
poll_pending_delete_confirmed_by_registrant: 'Registrant confirmed domain deletion'
manage: Manage
pending_epp: Pending epp

View file

@ -184,6 +184,7 @@ Rails.application.routes.draw do
resources :domains do
resources :domain_versions
resources :pendings
member do
post 'set_force_delete'
post 'unset_force_delete'