mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Merge branch 'master' into fix-for-ransack-deprecated-method
This commit is contained in:
commit
9cafc98482
171 changed files with 1061 additions and 726 deletions
|
@ -25,13 +25,12 @@ module Admin
|
|||
@account_activities = @q.result.page(params[:page]).per(params[:results_per_page])
|
||||
@count = @q.result.count
|
||||
|
||||
if params[:page] && params[:page].to_i > 1
|
||||
@sum = @q.result.limit(@account_activities.offset_value).sum(:sum) +
|
||||
@b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})")
|
||||
.sum(:sum)
|
||||
else
|
||||
@sum = @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
end
|
||||
@sum = if params[:page] && params[:page].to_i > 1
|
||||
@q.result.limit(@account_activities.offset_value).sum(:sum) +
|
||||
@b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
else
|
||||
@b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
|
@ -63,7 +63,12 @@ module Admin
|
|||
|
||||
def admin_user_params
|
||||
params.require(:admin_user).permit(:username,
|
||||
:password, :password_confirmation, :identity_code, :email, :country_code, { roles: [] })
|
||||
:password,
|
||||
:password_confirmation,
|
||||
:identity_code,
|
||||
:email,
|
||||
:country_code,
|
||||
{ roles: [] })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,9 +61,9 @@ module Admin
|
|||
end
|
||||
|
||||
def bank_statement_params
|
||||
params.require(:bank_statement).permit(:bank_code, :iban, bank_transactions_attributes: [
|
||||
:description, :sum, :currency, :reference_no, :paid_at
|
||||
])
|
||||
params.require(:bank_statement).permit(:bank_code, :iban, bank_transactions_attributes: %i[
|
||||
description sum currency reference_no paid_at
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,6 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def blocked_domain_params
|
||||
params.require(:blocked_domain).permit(:name)
|
||||
end
|
||||
|
|
|
@ -11,20 +11,22 @@ module Admin
|
|||
@versions = @q.result.page(params[:page])
|
||||
search_params = params[:q].deep_dup
|
||||
|
||||
whereS = "1=1"
|
||||
where_s = "1=1"
|
||||
|
||||
search_params.each do |key, value|
|
||||
next if value.empty?
|
||||
case key
|
||||
when 'event'
|
||||
whereS += " AND event = '#{value}'"
|
||||
else
|
||||
whereS += create_where_string(key, value)
|
||||
end
|
||||
|
||||
where_s += case key
|
||||
when 'event'
|
||||
" AND event = '#{value}'"
|
||||
else
|
||||
create_where_string(key, value)
|
||||
end
|
||||
end
|
||||
|
||||
versions = Version::ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
|
||||
@q = versions.ransack(params[:q])
|
||||
|
||||
@versions = @q.result.page(params[:page])
|
||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ module Admin
|
|||
params[:q] ||= {}
|
||||
search_params = params[:q].deep_dup
|
||||
|
||||
if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant')
|
||||
if search_params[:domain_contacts_type_in].is_a?(Array) &&
|
||||
search_params[:domain_contacts_type_in].delete('registrant')
|
||||
search_params[:registrant_domains_id_not_null] = 1
|
||||
end
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ module Admin
|
|||
|
||||
def show; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,27 +21,33 @@ module Admin
|
|||
search_params.delete(:registrar)
|
||||
end
|
||||
|
||||
whereS = "1=1"
|
||||
where_s = "1=1"
|
||||
|
||||
search_params.each do |key, value|
|
||||
next if value.empty?
|
||||
case key
|
||||
when 'event'
|
||||
whereS += " AND event = '#{value}'"
|
||||
when 'name'
|
||||
whereS += " AND (object->>'name' ~* '#{value}' OR object_changes->>'name' ~* '#{value}')"
|
||||
else
|
||||
whereS += create_where_string(key, value)
|
||||
end
|
||||
|
||||
where_s += case key
|
||||
when 'event'
|
||||
" AND event = '#{value}'"
|
||||
when 'name'
|
||||
" AND (object->>'name' ~* '#{value}' OR object_changes->>'name' ~* '#{value}')"
|
||||
else
|
||||
create_where_string(key, value)
|
||||
end
|
||||
end
|
||||
|
||||
whereS += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrants.present?
|
||||
whereS += " AND 1=0" if registrants == []
|
||||
whereS += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrars.present?
|
||||
whereS += " AND 1=0" if registrars == []
|
||||
if registrants.present?
|
||||
where_s += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id}'" }.join ','})"
|
||||
end
|
||||
where_s += " AND 1=0" if registrants == []
|
||||
if registrars.present?
|
||||
where_s += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id}'" }.join ','})"
|
||||
end
|
||||
where_s += " AND 1=0" if registrars == []
|
||||
|
||||
versions = Version::DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
|
||||
@q = versions.ransack(params[:q])
|
||||
|
||||
@versions = @q.result.page(params[:page])
|
||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
|
|
|
@ -5,20 +5,19 @@ 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
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = domains.ransack(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
if @domains.count == 1 && params[:q][:name_matches].present?
|
||||
redirect_to [:admin, @domains.first] and return
|
||||
elsif @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
|
||||
(redirect_to [:admin, @domains.first] and return if @domains.count == 1 && params[:q][:name_matches].present?)
|
||||
if @domains.count.zero? && params[:q][:name_matches] !~ /^%.+%$/
|
||||
# if we do not get any results, add wildcards to the name field and search again
|
||||
n_cache = params[:q][:name_matches]
|
||||
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
|
||||
|
@ -51,7 +50,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
|
||||
|
|
|
@ -3,17 +3,25 @@ module Admin
|
|||
load_and_authorize_resource class: ApiLog::EppLog
|
||||
before_action :set_default_dates, only: [:index]
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def index
|
||||
@q = ApiLog::EppLog.ransack(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
||||
@epp_logs = @q.result
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
|
||||
if params[:q][:created_at_gteq].present?
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
||||
Time.parse(params[:q][:created_at_gteq]))
|
||||
end
|
||||
if params[:q][:created_at_lteq].present?
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)",
|
||||
Time.parse(params[:q][:created_at_lteq]))
|
||||
end
|
||||
@epp_logs = @epp_logs.page(params[:page])
|
||||
|
||||
render_by_format('admin/epp_logs/index', 'epp_logs')
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def show
|
||||
@epp_log = ApiLog::EppLog.find(params[:id])
|
||||
|
|
|
@ -10,4 +10,4 @@ module Admin
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,19 +3,27 @@ module Admin
|
|||
load_and_authorize_resource class: ApiLog::ReppLog
|
||||
before_action :set_default_dates, only: [:index]
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def index
|
||||
@q = ApiLog::ReppLog.ransack(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
||||
@repp_logs = @q.result
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
|
||||
if params[:q][:created_at_gteq].present?
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
||||
Time.parse(params[:q][:created_at_gteq]))
|
||||
end
|
||||
if params[:q][:created_at_lteq].present?
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)",
|
||||
Time.parse(params[:q][:created_at_lteq]))
|
||||
end
|
||||
@repp_logs = @repp_logs.page(params[:page])
|
||||
@count = @q.result.count
|
||||
@repp_logs = @repp_logs.per(params[:results_per_page]) if paginate?
|
||||
|
||||
render_by_format('admin/repp_logs/index', 'repp_logs')
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def show
|
||||
@repp_log = ApiLog::ReppLog.find(params[:id])
|
||||
|
|
|
@ -14,4 +14,4 @@ module Admin
|
|||
current_admin_user ? current_admin_user.id_role_username : 'anonymous'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue