diff --git a/app/controllers/api/v1/registrant/registry_locks_controller.rb b/app/controllers/api/v1/registrant/registry_locks_controller.rb new file mode 100644 index 000000000..c3ec073b6 --- /dev/null +++ b/app/controllers/api/v1/registrant/registry_locks_controller.rb @@ -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 diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb index 4a41a06a3..5ae622353 100644 --- a/app/presenters/domain_presenter.rb +++ b/app/presenters/domain_presenter.rb @@ -14,6 +14,11 @@ class DomainPresenter html += " #{label}" end + if domain.locked_by_registrant? + label = view.content_tag(:span, 'registryLock', class: 'label label-danger') + html += " #{label}" + end + html.html_safe end diff --git a/app/views/admin/domains/edit.html.erb b/app/views/admin/domains/edit.html.erb index 335d3b574..19c093f78 100644 --- a/app/views/admin/domains/edit.html.erb +++ b/app/views/admin/domains/edit.html.erb @@ -1,12 +1,12 @@ <% domain = DomainPresenter.new(domain: @domain, view: self) %>