Disable namesservers massupdate

This commit is contained in:
Priit Tark 2015-05-19 16:25:29 +03:00
parent 66b00b7a77
commit 61cbc38a11
3 changed files with 48 additions and 44 deletions

View file

@ -1,46 +1,48 @@
class Registrar::NameserversController < RegistrarController
load_and_authorize_resource
# turned off requested by client
def index
if can_replace_hostnames?
prc = Nameserver.replace_hostname_ends(
current_user.registrar.domains.includes(
:registrant, :nameservers, :admin_domain_contacts, :tech_domain_contacts, :domain_statuses,
:versions, :admin_contacts, :tech_contacts, :whois_record, :dnskeys
),
params[:q][:hostname_end],
params[:hostname_end_replacement]
)
# load_and_authorize_resource
if prc == 'replaced_none'
flash.now[:alert] = t(:no_hostnames_replaced)
elsif prc == 'replaced_all'
params[:q][:hostname_end] = params[:hostname_end_replacement]
params[:hostname_end_replacement] = nil
flash.now[:notice] = t(:all_hostnames_replaced)
else
flash.now[:warning] = t(:hostnames_partially_replaced)
end
end
# def index
# if can_replace_hostnames?
# prc = Nameserver.replace_hostname_ends(
# current_user.registrar.domains.includes(
# :registrant, :nameservers, :admin_domain_contacts, :tech_domain_contacts, :domain_statuses,
# :versions, :admin_contacts, :tech_contacts, :whois_record, :dnskeys
# ),
# params[:q][:hostname_end],
# params[:hostname_end_replacement]
# )
nameservers = current_user.registrar.nameservers.includes(:domain)
@q = nameservers.search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@nameservers = @q.result.page(params[:page])
end
# if prc == 'replaced_none'
# flash.now[:alert] = t(:no_hostnames_replaced)
# elsif prc == 'replaced_all'
# params[:q][:hostname_end] = params[:hostname_end_replacement]
# params[:hostname_end_replacement] = nil
# flash.now[:notice] = t(:all_hostnames_replaced)
# else
# flash.now[:warning] = t(:hostnames_partially_replaced)
# end
# end
def replace_all
@domain_params = { nameservers_attributes: { 0 => {} } }
end
# nameservers = current_user.registrar.nameservers.includes(:domain)
# @q = nameservers.search(params[:q])
# @q.sorts = 'id desc' if @q.sorts.empty?
# @nameservers = @q.result.page(params[:page])
# end
private
# def replace_all
# @domain_params = { nameservers_attributes: { 0 => {} } }
# end
def can_replace_hostnames?
if params[:replace] && params[:q]
flash.now[:alert] = t('hostname_end_replacement_is_required') unless params[:hostname_end_replacement].present?
flash.now[:alert] = t('hostname_end_is_required') unless params[:q][:hostname_end].present?
return true if flash[:alert].blank?
end
false
end
# private
# def can_replace_hostnames?
# if params[:replace] && params[:q]
# flash.now[:alert] = t('hostname_end_replacement_is_required') unless params[:hostname_end_replacement].present?
# flash.now[:alert] = t('hostname_end_is_required') unless params[:q][:hostname_end].present?
# return true if flash[:alert].blank?
# end
# false
# end
end

View file

@ -1,8 +1,9 @@
- content_for :actions do
= link_to(t(:new), new_registrar_domain_path, class: 'btn btn-primary')
= link_to(t(:transfer), transfer_registrar_domains_path, class: 'btn btn-default')
-# turned off requested by client
-# = link_to(t(:keyrelay), registrar_keyrelay_path, class: 'btn btn-default')
= link_to(t(:nameservers), registrar_nameservers_path, class: 'btn btn-default')
-# = link_to(t(:nameservers), registrar_nameservers_path, class: 'btn btn-default')
= render 'shared/title', name: t(:domains)
.row

View file

@ -57,11 +57,12 @@ Rails.application.routes.draw do
end
end
resources :nameservers do
collection do
match 'replace_all', via: [:post, :get]
end
end
# turned off requested by client
# resources :nameservers do
# collection do
# match 'replace_all', via: [:post, :get]
# end
# end
resources :contacts do
member do