Merge pull request #1533 from internetee/1481-add_client_hold_to_registrar_ui

1481 add client hold to registrar ui
This commit is contained in:
Timo Võhmar 2020-02-26 17:17:59 +02:00 committed by GitHub
commit 3d9e8d2c26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 0 deletions

View file

@ -59,6 +59,7 @@ class Registrar
def info
authorize! :info, Depp::Domain
@data = @domain.info(params[:domain_name]) if params[:domain_name]
@client_holded = client_holded(@data)
if response_ok?
render 'info'
else
@ -153,12 +154,26 @@ class Registrar
render json: scope.pluck(:name, :code).map { |c| { display_key: "#{c.second} #{c.first}", value: c.second } }
end
def remove_hold
authorize! :remove_hold, Depp::Domain
return unless params[:domain_name]
@data = @domain.remove_hold(params)
flash[:alert] = @data.css('msg').text unless response_ok?
redirect_to info_registrar_domains_url(domain_name: params[:domain_name])
end
private
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
def client_holded(data)
data.css('status')&.map { |element| element.attribute('s').value }
&.any? { |status| status == DomainStatus::CLIENT_HOLD }
end
def contacts
current_registrar_user.registrar.contacts

View file

@ -50,6 +50,7 @@ class Ability
can(:check, Epp::Domain)
can(:create, Epp::Domain)
can(:renew, Epp::Domain) { |d| d.registrar_id == @user.registrar_id }
can(:remove_hold, Epp::Domain) { |d| d.registrar_id == @user.registrar_id }
can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
can(:transfer, Epp::Domain)
can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }

View file

@ -0,0 +1,9 @@
module RemoveHold
extend ActiveSupport::Concern
def remove_hold(params)
xml = epp_xml.update(name: { value: params[:domain_name] },
rem: [status: { attrs: { s: 'clientHold' }, value: '' }])
current_user.request(xml)
end
end

View file

@ -1,6 +1,7 @@
module Depp
class Domain
include ActiveModel::Conversion
include RemoveHold
extend ActiveModel::Naming
attr_accessor :name, :current_user, :epp_xml

View file

@ -6,6 +6,10 @@
class: 'btn btn-default') %>
<%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default') %>
<% if @client_holded %>
<%= link_to(t(:remove_client_hold), remove_hold_registrar_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default') %>
<% end %>
<% else %>
<%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path(domain_name: params[:domain_name]),
class: 'btn btn-default' %>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>example.ee</domain:name>
<domain:rem>
<domain:status s="clientHold"/>
</domain:rem>
</domain:update>
</update>
<clTRID>timo-1579351654</clTRID>
</command>
</epp>

View file

@ -29,6 +29,9 @@
,
%a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'delete'}}
Delete
,
%a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'client_hold'}}
Remove Client Hold
%h4 Poll
%a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'poll', epp_action: 'poll'}}

View file

@ -206,6 +206,7 @@ en:
statuses: 'Statuses'
description: 'Description'
delete: 'Delete'
remove_client_hold: 'Remove clientHold'
are_you_sure: 'Are you sure?'
back: 'Back'
new_domain: 'New domain'
@ -580,6 +581,7 @@ en:
tech: Tech contact
valid: Valid
object_is_not_eligible_for_renewal: 'Object is not eligible for renewal'
object_is_not_holded: 'Object is not holded'
bank_statement_desc: 'Import file row will match only when matching following attributes: <b><br>ref number<br>payment amount<br>invoice number (the first numerical value in comment field)</b>.'
create_bank_statement: 'Create bank statement'
create_bank_transaction: 'Create bank transaction'

View file

@ -99,6 +99,7 @@ Rails.application.routes.draw do
get 'check'
get 'delete'
get 'search_contacts'
get 'remove_hold'
end
end
resources :domain_transfers, only: %i[new create]