mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Add badges to locked domains
This commit is contained in:
parent
7ce092dff2
commit
faeeb55bc7
8 changed files with 80 additions and 7 deletions
|
@ -0,0 +1,37 @@
|
||||||
|
module Api
|
||||||
|
module V1
|
||||||
|
module Registrant
|
||||||
|
class RegistryLocksController < BaseController
|
||||||
|
before_action :set_domain
|
||||||
|
|
||||||
|
def create
|
||||||
|
if @domain.apply_registry_lock
|
||||||
|
render json: @domain
|
||||||
|
else
|
||||||
|
render json: { errors: [{ base: 'Domain cannot be locked' }] },
|
||||||
|
status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete
|
||||||
|
if @domain.remove_registry_lock
|
||||||
|
render json: @domain
|
||||||
|
else
|
||||||
|
render json: { errors: [{ base: 'Domain cannot be unlocked' }] },
|
||||||
|
status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_domain
|
||||||
|
@domain = Domain.find_by(uuid: params[:domain_uuid])
|
||||||
|
|
||||||
|
return if @domain
|
||||||
|
render json: { errors: [{ base: ['Domain not found'] }] },
|
||||||
|
status: :not_found and return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,6 +14,11 @@ class DomainPresenter
|
||||||
html += " #{label}"
|
html += " #{label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if domain.locked_by_registrant?
|
||||||
|
label = view.content_tag(:span, 'registryLock', class: 'label label-danger')
|
||||||
|
html += " #{label}"
|
||||||
|
end
|
||||||
|
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<% domain = DomainPresenter.new(domain: @domain, view: self) %>
|
<% domain = DomainPresenter.new(domain: @domain, view: self) %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-8">
|
||||||
<h1 class="text-center-xs">
|
<h1 class="text-center-xs">
|
||||||
Edit: <%= domain.name %>
|
Edit: <%= domain.name_with_status %>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-7 text-right">
|
<div class="col-sm-4 text-right">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<%= link_to t('.back_btn'), [:admin, @domain], class: 'btn btn-default' %>
|
<%= link_to t('.back_btn'), [:admin, @domain], class: 'btn btn-default' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,7 +25,8 @@ en:
|
||||||
|
|
||||||
registry_lock_delete:
|
registry_lock_delete:
|
||||||
btn: Remove registry lock
|
btn: Remove registry lock
|
||||||
confirm: Are you sure you want to remove registry lock that was set by registrant?
|
banner: Domain has a registry lock set by registrant.
|
||||||
|
confirm: Are you sure you want to remove the registry lock?
|
||||||
success: Registry lock removed
|
success: Registry lock removed
|
||||||
error: Registry lock could not be removed
|
error: Registry lock could not be removed
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,9 @@ Rails.application.routes.draw do
|
||||||
namespace :registrant do
|
namespace :registrant do
|
||||||
post 'auth/eid', to: 'auth#eid'
|
post 'auth/eid', to: 'auth#eid'
|
||||||
|
|
||||||
resources :domains, only: [:index]
|
resources :domains, only: [:index], param: :uuid do
|
||||||
|
resource :registry_lock, only: [:create, :destroy]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
require 'test_helper'
|
||||||
|
require 'auth_token/auth_token_creator'
|
||||||
|
|
||||||
|
class RegistrantApiDomainRegistryLockTest < ApplicationIntegrationTest
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
|
||||||
|
@user = users(:registrant)
|
||||||
|
@domain = domains(:airport)
|
||||||
|
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_can_lock_a_not_locked_domain
|
||||||
|
assert(@domain.locked_by_registrant?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_cannot_lock_an_already_locked_domain
|
||||||
|
assert(@domain.locked_by_registrant?)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def auth_token
|
||||||
|
token_creator = AuthTokenCreator.create_with_defaults(@user)
|
||||||
|
hash = token_creator.token_in_hash
|
||||||
|
"Bearer #{hash[:access_token]}"
|
||||||
|
end
|
||||||
|
end
|
|
@ -26,7 +26,7 @@ class RegistryLockTest < JavaScriptApplicationSystemTestCase
|
||||||
click_link_or_button('Actions')
|
click_link_or_button('Actions')
|
||||||
assert(page.has_link?('Remove registry lock'))
|
assert(page.has_link?('Remove registry lock'))
|
||||||
|
|
||||||
accept_confirm('Are you sure you want to remove registry lock that was set by registrant?') do
|
accept_confirm('Are you sure you want to remove registry lock?') do
|
||||||
click_link_or_button('Remove registry lock')
|
click_link_or_button('Remove registry lock')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue