Extract domain transfers controller

#660
This commit is contained in:
Artur Beljajev 2018-01-22 16:29:37 +02:00
parent d64686777c
commit b11b6f7d8b
10 changed files with 33 additions and 20 deletions

View file

@ -0,0 +1,15 @@
class Registrar
class DomainTransfersController < DeppController
before_action do
authorize! :transfer, Depp::Domain
end
def new
end
def create
domain = Depp::Domain.new(current_user: depp_current_user)
@data = domain.transfer(params)
end
end
end

View file

@ -146,16 +146,6 @@ class Registrar
end end
end end
def transfer
authorize! :transfer, Depp::Domain
if request.post? && params[:domain_name]
@data = @domain.transfer(params)
render 'transfer_index' and return unless response_ok?
else
render 'transfer_index'
end
end
def search_contacts def search_contacts
authorize! :create, Depp::Domain authorize! :create, Depp::Domain

View file

@ -6,7 +6,7 @@
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<%= form_tag transfer_registrar_domains_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %> <%= form_tag registrar_domain_transfers_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %>
<div class="form-group"> <div class="form-group">
<div class="col-md-3 control-label"> <div class="col-md-3 control-label">
<%= label_tag :domain_name, t(:name), class: 'required' %> <%= label_tag :domain_name, t(:name), class: 'required' %>

View file

@ -6,7 +6,7 @@
<div class="col-sm-3 text-right"> <div class="col-sm-3 text-right">
<%= link_to t('.new_btn'), new_registrar_domain_path, class: 'btn btn-primary' %> <%= link_to t('.new_btn'), new_registrar_domain_path, class: 'btn btn-primary' %>
<%= link_to t('.transfer_btn'), transfer_registrar_domains_path, class: 'btn btn-default' %> <%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path, class: 'btn btn-default' %>
</div> </div>
</div> </div>
</div> </div>

View file

@ -7,7 +7,7 @@
<%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]), <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default') %> class: 'btn btn-default') %>
<% else %> <% else %>
<%= link_to(t(:transfer), transfer_registrar_domains_path(domain_name: params[:domain_name]), <%= link_to(t(:transfer), new_registrar_domain_transfer_path(domain_name: params[:domain_name]),
class: 'btn btn-default') %> class: 'btn btn-default') %>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -0,0 +1,8 @@
en:
registrar:
domain_transfers:
new:
header: Domain transfer
create:
header: Domain transfer

View file

@ -12,12 +12,6 @@ en:
registrant_code: Registrant code registrant_code: Registrant code
expire_time: Date of expiry expire_time: Date of expiry
transfer_index:
header: Domain transfer
transfer:
header: Domain transfer
search_form: search_form:
download_btn: Download as CSV download_btn: Download as CSV
reset_btn: Reset reset_btn: Reset

View file

@ -54,7 +54,6 @@ Rails.application.routes.draw do
post 'update', as: 'update' post 'update', as: 'update'
post 'destroy', as: 'destroy' post 'destroy', as: 'destroy'
get 'renew' get 'renew'
match 'transfer', via: [:post, :get]
get 'edit' get 'edit'
get 'info' get 'info'
get 'check' get 'check'
@ -62,6 +61,7 @@ Rails.application.routes.draw do
get 'search_contacts' get 'search_contacts'
end end
end end
resources :domain_transfers, only: %i[new create]
resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do
member do member do

View file

@ -29,4 +29,10 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest
assert_text 'Transfer requested at: 2010-07-05 10:30:00' assert_text 'Transfer requested at: 2010-07-05 10:30:00'
end end
def test_prefills_domain_transfer_form
visit info_registrar_domains_url(domain_name: 'airport.test')
click_link 'Transfer'
assert_field 'domain_name', with: 'airport.test'
end
end end