Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1481 add client hold to registrar ui #1533

Merged
merged 3 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/controllers/registrar/domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def index
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
Expand Down Expand Up @@ -153,12 +154,26 @@ def search_contacts
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
Expand Down
1 change: 1 addition & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def epp # Registrar/api_user dynamic role
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 }
Expand Down
9 changes: 9 additions & 0 deletions app/models/concerns/remove_hold.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions app/models/depp/domain.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Depp
class Domain
include ActiveModel::Conversion
include RemoveHold
extend ActiveModel::Naming

attr_accessor :name, :current_user, :epp_xml
Expand Down
4 changes: 4 additions & 0 deletions app/views/registrar/domains/info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' %>
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 3 additions & 0 deletions app/views/registrar/xml_consoles/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
get 'check'
get 'delete'
get 'search_contacts'
get 'remove_hold'
end
end
resources :domain_transfers, only: %i[new create]
Expand Down