Add remove clientHold to registrar UI

This commit is contained in:
Alex Sherman 2020-02-19 14:09:45 +05:00
parent adba253d01
commit 3b332da0bb
9 changed files with 30 additions and 0 deletions

View file

@ -153,6 +153,14 @@ 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)
redirect_to info_registrar_domains_url(domain_name: params[:domain_name])
end
private
def init_domain

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

@ -34,6 +34,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
force_delete_start.present? && force_delete_lte_today && force_delete_lte_valid_date
end
def client_holded?
statuses.include?(DomainStatus::CLIENT_HOLD)
end
def force_delete_lte_today
force_delete_start + Setting.expire_warning_period.days <= Time.zone.now
end

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

@ -9,5 +9,9 @@
class: 'btn btn-default btn-xs' %>
<%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name),
class: 'btn btn-default btn-xs' %>
<% if domain.client_holded? %>
<%= link_to t('.client_hold_btn'), remove_hold_registrar_domains_path(domain_name: domain.name),
class: 'btn btn-default btn-xs' %>
<% end %>
</td>
</tr>