mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
fixed search form
This commit is contained in:
parent
fd34d3330d
commit
fee6b897af
2 changed files with 23 additions and 11 deletions
|
@ -5,13 +5,15 @@ module Admin
|
|||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
if params[:statuses_contains]
|
||||
domains = Domain.includes(:registrar, :registrant).where(
|
||||
"domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
||||
)
|
||||
else
|
||||
domains = Domain.includes(:registrar, :registrant)
|
||||
end
|
||||
domains = if params[:statuses_contains]
|
||||
Domain.includes(:registrar, :registrant).where(
|
||||
'domains.statuses @> ?::varchar[]', "{#{params[:statuses_contains].join(',')}}"
|
||||
)
|
||||
else
|
||||
Domain.includes(:registrar, :registrant)
|
||||
end
|
||||
|
||||
domains = get_domains_which_related_to_registrars
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
|
@ -59,7 +61,7 @@ module Admin
|
|||
redirect_to [:admin, @domain]
|
||||
else
|
||||
build_associations
|
||||
flash.now[:alert] = I18n.t('failed_to_update_domain') + ' ' + @domain.errors.full_messages.join(", ")
|
||||
flash.now[:alert] = I18n.t('failed_to_update_domain') + ' ' + @domain.errors.full_messages.join(', ')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
@ -105,7 +107,7 @@ module Admin
|
|||
begin
|
||||
end_time = params[:q][:valid_to_lteq].try(:to_date)
|
||||
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
|
||||
rescue
|
||||
rescue StandardError
|
||||
logger.warn('Invalid date')
|
||||
end
|
||||
|
||||
|
@ -113,5 +115,15 @@ module Admin
|
|||
|
||||
params[:q][:valid_to_lteq] = ca_cache
|
||||
end
|
||||
|
||||
def get_domains_which_related_to_registrars
|
||||
if params[:registrar_id_eq]
|
||||
Domain.includes(:registrar, :registrant).where(
|
||||
registrar: params[:registrar_id_eq]
|
||||
)
|
||||
else
|
||||
Domain.includes(:registrar, :registrant)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue