mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Allow searching other registrar domain #2678
This commit is contained in:
parent
9c5d314d21
commit
92f52548bb
2 changed files with 12 additions and 4 deletions
|
@ -5,10 +5,19 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
||||||
# rubocop: disable Metrics/PerceivedComplexity
|
# rubocop: disable Metrics/PerceivedComplexity
|
||||||
# rubocop: disable Metrics/CyclomaticComplexity
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
# rubocop: disable Metrics/AbcSize
|
# rubocop: disable Metrics/AbcSize
|
||||||
|
# rubocop: disable Metrics/MethodLength
|
||||||
def index
|
def index
|
||||||
authorize! :view, Depp::Domain
|
authorize! :view, Depp::Domain
|
||||||
|
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
|
params[:q].delete_if { |_k, v| v.blank? }
|
||||||
|
if params[:q].length == 1 && params[:q][:name_matches].present?
|
||||||
|
@domain = Domain.find_by(name: params[:q][:name_matches])
|
||||||
|
if @domain
|
||||||
|
redirect_to info_registrar_domains_path(domain_name: @domain.name) and return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if params[:statuses_contains]
|
if params[:statuses_contains]
|
||||||
domains = current_user.registrar.domains.includes(:registrar, :registrant).where(
|
domains = current_user.registrar.domains.includes(:registrar, :registrant).where(
|
||||||
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
||||||
|
@ -20,9 +29,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = domains.search(params[:q])
|
@q = domains.search(params[:q])
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
if @domains.count == 1 && params[:q][:name_matches].present?
|
if @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
|
||||||
redirect_to info_registrar_domains_path(domain_name: @domains.first.name) and return
|
|
||||||
elsif @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
|
|
||||||
# if we do not get any results, add wildcards to the name field and search again
|
# if we do not get any results, add wildcards to the name field and search again
|
||||||
n_cache = params[:q][:name_matches]
|
n_cache = params[:q][:name_matches]
|
||||||
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
|
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
|
||||||
|
|
|
@ -94,7 +94,8 @@ feature 'Domains', type: :feature do
|
||||||
|
|
||||||
fill_in 'q_name_matches', with: 'abcd_.ee'
|
fill_in 'q_name_matches', with: 'abcd_.ee'
|
||||||
find('.btn.btn-primary.search').click
|
find('.btn.btn-primary.search').click
|
||||||
current_path.should == "/registrar/domains/info"
|
current_path.should == "/registrar/domains"
|
||||||
|
page.should have_content('abcde.ee')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue