mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 15:14:47 +02:00
added filter for domain and contact histories
This commit is contained in:
parent
34e16ab8e8
commit
15c606f76a
4 changed files with 28 additions and 26 deletions
|
@ -7,11 +7,9 @@ module Admin
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
|
|
||||||
@q = Version::ContactVersion.ransack(params[:q])
|
search_params = params[:q].deep_dup.except(:created_at_gteq, :created_at_lteq)
|
||||||
@versions = @q.result.page(params[:page])
|
|
||||||
search_params = params[:q].deep_dup
|
|
||||||
|
|
||||||
where_s = "1=1"
|
where_s = '1=1'
|
||||||
|
|
||||||
search_params.each do |key, value|
|
search_params.each do |key, value|
|
||||||
next if value.empty?
|
next if value.empty?
|
||||||
|
|
|
@ -7,21 +7,19 @@ module Admin
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
|
|
||||||
@q = Version::DomainVersion.includes(:item).ransack(params[:q])
|
search_params = params[:q].deep_dup.except(:created_at_gteq, :created_at_lteq)
|
||||||
@versions = @q.result.page(params[:page])
|
|
||||||
search_params = params[:q].deep_dup
|
|
||||||
|
|
||||||
if search_params[:registrant].present?
|
if search_params[:registrant].present?
|
||||||
registrants = Contact.where("name ilike ?", "%#{search_params[:registrant].strip}%")
|
registrants = Contact.where('name ilike ?', "%#{search_params[:registrant].strip}%")
|
||||||
search_params.delete(:registrant)
|
search_params.delete(:registrant)
|
||||||
end
|
end
|
||||||
|
|
||||||
if search_params[:registrar].present?
|
if search_params[:registrar].present?
|
||||||
registrars = Registrar.where("name ilike ?", "%#{search_params[:registrar].strip}%")
|
registrars = Registrar.where('name ilike ?', "%#{search_params[:registrar].strip}%")
|
||||||
search_params.delete(:registrar)
|
search_params.delete(:registrar)
|
||||||
end
|
end
|
||||||
|
|
||||||
where_s = "1=1"
|
where_s = '1=1'
|
||||||
|
|
||||||
search_params.each do |key, value|
|
search_params.each do |key, value|
|
||||||
next if value.empty?
|
next if value.empty?
|
||||||
|
@ -39,11 +37,11 @@ module Admin
|
||||||
if registrants.present?
|
if registrants.present?
|
||||||
where_s += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id}'" }.join ','})"
|
where_s += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id}'" }.join ','})"
|
||||||
end
|
end
|
||||||
where_s += " AND 1=0" if registrants == []
|
where_s += ' AND 1=0' if registrants == []
|
||||||
if registrars.present?
|
if registrars.present?
|
||||||
where_s += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id}'" }.join ','})"
|
where_s += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id}'" }.join ','})"
|
||||||
end
|
end
|
||||||
where_s += " AND 1=0" if registrars == []
|
where_s += ' AND 1=0' if registrars == []
|
||||||
|
|
||||||
versions = Version::DomainVersion.includes(:item).where(where_s).order(created_at: :desc, id: :desc)
|
versions = Version::DomainVersion.includes(:item).where(where_s).order(created_at: :desc, id: :desc)
|
||||||
@q = versions.ransack(params[:q])
|
@q = versions.ransack(params[:q])
|
||||||
|
|
|
@ -21,19 +21,25 @@
|
||||||
= label_tag :action
|
= label_tag :action
|
||||||
= select_tag '[q][event]', options_for_select([['Update', 'update'], ['Destroy', 'destroy'], ['Create', 'create']], params[:q][:event]), { include_blank:true, multiple: false, placeholder: t(:choose), class: 'form-control js-combobox' }
|
= select_tag '[q][event]', options_for_select([['Update', 'update'], ['Destroy', 'destroy'], ['Create', 'create']], params[:q][:event]), { include_blank:true, multiple: false, placeholder: t(:choose), class: 'form-control js-combobox' }
|
||||||
.row
|
.row
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.col-md-3
|
.form-group
|
||||||
.col-md-3
|
= f.label t(:created_at_from)
|
||||||
.form-group
|
= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:created_at_from)
|
||||||
= label_tag t(:results_per_page)
|
.col-md-3
|
||||||
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
|
.form-group
|
||||||
.col-md-3{style: 'padding-top: 25px;float:right;padding-right: 0px;'}
|
= f.label t(:created_at_until)
|
||||||
%button.btn.btn-primary
|
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:created_at_until)
|
||||||
|
.col-md-3
|
||||||
%span.glyphicon.glyphicon-search
|
.form-group
|
||||||
|
= label_tag t(:results_per_page)
|
||||||
= link_to(t('.csv_btn'), admin_contact_versions_path(format: :csv, params: params.permit!), class: 'btn btn-default')
|
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
|
||||||
= link_to(t('.reset_btn'), admin_contact_versions_path, class: 'btn btn-default')
|
.col-md-3{style: 'padding-top: 25px;float:right;padding-right: 0px;'}
|
||||||
|
%button.btn.btn-primary
|
||||||
|
|
||||||
|
%span.glyphicon.glyphicon-search
|
||||||
|
|
||||||
|
= link_to(t('.csv_btn'), admin_contact_versions_path(format: :csv, params: params.permit!), class: 'btn btn-default')
|
||||||
|
= link_to(t('.reset_btn'), admin_contact_versions_path, class: 'btn btn-default')
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag t(:registrar_name)
|
= label_tag t(:registrar_name)
|
||||||
= select_tag '[q][registrar]', options_for_select(Registrar.all.map { |x| [x, x.name] }, selected: params[:q][:registrar]), { include_blank: true, class: 'form-control', placeholder: t('.registrant')}
|
= select_tag '[q][registrar]', options_for_select(Registrar.all.map { |r| [r.name] }, selected: params[:q][:registrar]), { include_blank: true, class: 'form-control', placeholder: t('.registrant')}
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag :action
|
= label_tag :action
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue