mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Add a view and routes
This commit is contained in:
parent
489cd2f7e5
commit
fca12fdb34
9 changed files with 119 additions and 9 deletions
|
@ -16,8 +16,10 @@ plugins:
|
|||
enabled: true
|
||||
config:
|
||||
languages:
|
||||
- ruby
|
||||
- javascript
|
||||
ruby:
|
||||
mass_threshold: 100
|
||||
javascript:
|
||||
mass_threshold: 100
|
||||
eslint:
|
||||
enabled: true
|
||||
channel: eslint-5
|
||||
|
|
19
app/controllers/registrar/admin_contacts_controller.rb
Normal file
19
app/controllers/registrar/admin_contacts_controller.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class Registrar
|
||||
class AdminContactsController < BulkChangeController
|
||||
BASE_URL = URI.parse("#{ENV['repp_url']}domains/admin_contacts").freeze
|
||||
ACTIVE_TAB = :admin_contact
|
||||
|
||||
def update
|
||||
authorize! :manage, :repp
|
||||
|
||||
uri = BASE_URL
|
||||
request = form_request(uri)
|
||||
response = do_request(request, uri)
|
||||
start_notice = t('.replaced')
|
||||
|
||||
process_response(response: response,
|
||||
start_notice: start_notice,
|
||||
active_tab: ACTIVE_TAB)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -26,6 +26,15 @@ class Registrar
|
|||
|
||||
private
|
||||
|
||||
def form_request(uri)
|
||||
request = Net::HTTP::Patch.new(uri)
|
||||
request.set_form_data(current_contact_id: params[:current_contact_id],
|
||||
new_contact_id: params[:new_contact_id])
|
||||
request.basic_auth(current_registrar_user.username,
|
||||
current_registrar_user.plain_text_password)
|
||||
request
|
||||
end
|
||||
|
||||
def process_response(response:, start_notice: '', active_tab:)
|
||||
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
|
|
@ -7,14 +7,8 @@ class Registrar
|
|||
authorize! :manage, :repp
|
||||
|
||||
uri = BASE_URL
|
||||
request = Net::HTTP::Patch.new(uri)
|
||||
request.set_form_data(current_contact_id: params[:current_contact_id],
|
||||
new_contact_id: params[:new_contact_id])
|
||||
request.basic_auth(current_registrar_user.username,
|
||||
current_registrar_user.plain_text_password)
|
||||
|
||||
request = form_request(uri)
|
||||
response = do_request(request, uri)
|
||||
|
||||
start_notice = t('.replaced')
|
||||
|
||||
process_response(response: response,
|
||||
|
|
60
app/views/registrar/bulk_change/_admin_contact_form.html.erb
Normal file
60
app/views/registrar/bulk_change/_admin_contact_form.html.erb
Normal file
|
@ -0,0 +1,60 @@
|
|||
<%= form_tag registrar_admin_contacts_path, method: :patch, class: 'form-horizontal' do %>
|
||||
<% if @error %>
|
||||
<div class="alert alert-danger">
|
||||
<%= @error %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-2 control-label">
|
||||
<%= label_tag :current_contact_id, t('.current_contact_id') %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= text_field_tag :current_contact_id, params[:current_contact_id],
|
||||
list: :contacts,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-2 control-label">
|
||||
<%= label_tag :new_contact_id, t('.new_contact_id') %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= text_field_tag :new_contact_id, params[:new_contact_id],
|
||||
list: :contacts,
|
||||
required: true,
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-4 col-md-offset-2 text-right">
|
||||
<button class="btn btn-warning">
|
||||
<%= t '.submit_btn' %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-default btn-xs" role="button" data-toggle="collapse"
|
||||
href="#bulk_change_tech_contact_help"><%= t '.help_btn' %></a>
|
||||
<div class="collapse" id="bulk_change_tech_contact_help">
|
||||
<div class="well">
|
||||
<%= t '.help' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<datalist id="contacts">
|
||||
<% available_contacts.each do |data| %>
|
||||
<option value="<%= data.second %>"><%= data.first %></option>
|
||||
<% end %>
|
||||
</datalist>
|
|
@ -12,6 +12,10 @@
|
|||
<a href="#technical_contact" data-toggle="tab"><%= t '.technical_contact' %></a>
|
||||
</li>
|
||||
|
||||
<li class="<%= 'active' if active_tab == :admin_contact %>">
|
||||
<a href="#admin_contact" data-toggle="tab"><%= t '.admin_contact' %></a>
|
||||
</li>
|
||||
|
||||
<li class="<%= 'active' if active_tab == :nameserver %>">
|
||||
<a href="#nameserver" data-toggle="tab"><%= t '.nameserver' %></a>
|
||||
</li>
|
||||
|
@ -31,6 +35,11 @@
|
|||
<%= render 'tech_contact_form', available_contacts: available_contacts %>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane<%= ' active' if active_tab == :admin_contact %>"
|
||||
id="admin_contact">
|
||||
<%= render 'admin_contact_form', available_contacts: available_contacts %>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane<%= ' active' if active_tab == :nameserver %>" id="nameserver">
|
||||
<%= render 'nameserver_form' %>
|
||||
</div>
|
||||
|
|
6
config/locales/registrar/admin_contacts.en.yml
Normal file
6
config/locales/registrar/admin_contacts.en.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
en:
|
||||
registrar:
|
||||
admin_contacts:
|
||||
update:
|
||||
replaced: Admin contacts have been successfully replaced.
|
||||
replaced: Technical contacts have been successfully replaced.
|
|
@ -18,6 +18,16 @@ en:
|
|||
Replace technical contact specified in "current contact ID" with the one in "new
|
||||
contact ID" on any domain registered under this registrar
|
||||
|
||||
admin_contact_form:
|
||||
current_contact_id: Current admin contact ID
|
||||
new_contact_id: New admin contact ID
|
||||
submit_btn: Replace admin contacts
|
||||
help_btn: Toggle help
|
||||
help: >-
|
||||
Replace admin contact specified in "current contact ID" with the one in "new
|
||||
contact ID" on any domain registered under this registrar. Contact idents must
|
||||
be the same
|
||||
|
||||
nameserver_form:
|
||||
ip_hint: One IP per line
|
||||
replace_btn: Replace nameserver
|
||||
|
|
|
@ -137,6 +137,7 @@ Rails.application.routes.draw do
|
|||
resource :bulk_change, controller: :bulk_change, only: :new
|
||||
post '/bulk_renew/new', to: 'bulk_change#bulk_renew', as: :bulk_renew
|
||||
resource :tech_contacts, only: :update
|
||||
resource :admin_contacts, only: :update
|
||||
resource :nameservers, only: :update
|
||||
resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do
|
||||
member do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue