mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 05:56:20 +02:00
Merge pull request #2555 from internetee/2553-admin-domain-filter
Fixed ransack admin search
This commit is contained in:
commit
3126973f24
35 changed files with 172 additions and 128 deletions
|
@ -4,7 +4,8 @@ module Admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = Account.includes(:registrar).ransack(params[:q])
|
@q = Account.includes(:registrar).ransack(params[:q])
|
||||||
@accounts = @q.result.page(params[:page])
|
@result = @q.result
|
||||||
|
@accounts = @result.page(params[:page])
|
||||||
@accounts = @accounts.per(params[:results_per_page]) if paginate?
|
@accounts = @accounts.per(params[:results_per_page]) if paginate?
|
||||||
|
|
||||||
render_by_format('admin/accounts/index', 'accounts')
|
render_by_format('admin/accounts/index', 'accounts')
|
||||||
|
|
|
@ -15,7 +15,8 @@ module Admin
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
|
@q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@auctions = @q.result.page(params[:page])
|
@result = @q.result
|
||||||
|
@auctions = @result.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
@auctions = @auctions.per(params[:results_per_page_auction]) if params[:results_per_page_auction].to_i.positive?
|
@auctions = @auctions.per(params[:results_per_page_auction]) if params[:results_per_page_auction].to_i.positive?
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Admin
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render page }
|
format.html { render page }
|
||||||
format.csv do
|
format.csv do
|
||||||
raw_csv = CsvGenerator.generate_csv(@q.result)
|
raw_csv = CsvGenerator.generate_csv(@result)
|
||||||
send_data raw_csv,
|
send_data raw_csv,
|
||||||
filename: "#{filename}_#{Time.zone.now.to_formatted_s(:number)}.csv",
|
filename: "#{filename}_#{Time.zone.now.to_formatted_s(:number)}.csv",
|
||||||
type: "#{Mime[:csv]}; charset=utf-8"
|
type: "#{Mime[:csv]}; charset=utf-8"
|
||||||
|
|
|
@ -6,7 +6,8 @@ module Admin
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
domains = BlockedDomain.all.order(:name)
|
domains = BlockedDomain.all.order(:name)
|
||||||
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@domains = @q.result.page(params[:page])
|
@result = @q.result
|
||||||
|
@domains = @result.page(params[:page])
|
||||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
||||||
render_by_format('admin/blocked_domains/index', 'blocked_domains')
|
render_by_format('admin/blocked_domains/index', 'blocked_domains')
|
||||||
|
|
|
@ -10,8 +10,8 @@ module Admin
|
||||||
search_params = PartialSearchFormatter.format(fix_date_params)
|
search_params = PartialSearchFormatter.format(fix_date_params)
|
||||||
versions = Version::ContactVersion.includes(:item).order(created_at: :desc, id: :desc)
|
versions = Version::ContactVersion.includes(:item).order(created_at: :desc, id: :desc)
|
||||||
@q = versions.ransack(polymorphic_association(search_params))
|
@q = versions.ransack(polymorphic_association(search_params))
|
||||||
|
@result = @q.result
|
||||||
@versions = @q.result.page(params[:page])
|
@versions = @result.page(params[:page])
|
||||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
||||||
render_by_format('admin/contact_versions/index', 'contact_history')
|
render_by_format('admin/contact_versions/index', 'contact_history')
|
||||||
|
@ -24,7 +24,7 @@ module Admin
|
||||||
@versions_map = @versions.all.map(&:id)
|
@versions_map = @versions.all.map(&:id)
|
||||||
|
|
||||||
# what we do is calc amount of results until needed version
|
# what we do is calc amount of results until needed version
|
||||||
# then we cacl which page it is
|
# then we calc which page it is
|
||||||
if params[:page].blank?
|
if params[:page].blank?
|
||||||
counter = @versions_map.index(@version.id) + 1
|
counter = @versions_map.index(@version.id) + 1
|
||||||
page = counter / per_page
|
page = counter / per_page
|
||||||
|
|
|
@ -19,7 +19,8 @@ module Admin
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = contacts.ransack(PartialSearchFormatter.format(search_params))
|
@q = contacts.ransack(PartialSearchFormatter.format(search_params))
|
||||||
@contacts = @q.result.distinct.page(params[:page])
|
@result = @q.result.distinct
|
||||||
|
@contacts = @result.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
|
@ -57,7 +57,8 @@ module Admin
|
||||||
|
|
||||||
def sortable_dispute_query_for(disputes, query, closed: false)
|
def sortable_dispute_query_for(disputes, query, closed: false)
|
||||||
@q = disputes.order(:domain_name).ransack(query)
|
@q = disputes.order(:domain_name).ransack(query)
|
||||||
disputes = @q.result.page(closed ? params[:closed_page] : params[:page])
|
@result = @q.result
|
||||||
|
disputes = @result.page(closed ? params[:closed_page] : params[:page])
|
||||||
return disputes.per(params[:results_per_page]) if params[:results_per_page].present?
|
return disputes.per(params[:results_per_page]) if params[:results_per_page].present?
|
||||||
|
|
||||||
disputes
|
disputes
|
||||||
|
|
|
@ -47,8 +47,8 @@ module Admin
|
||||||
|
|
||||||
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(fix_date_params)
|
@q = versions.ransack(fix_date_params)
|
||||||
|
@result = @q.result
|
||||||
@versions = @q.result.page(params[:page])
|
@versions = @result.page(params[:page])
|
||||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
||||||
render_by_format('admin/domain_versions/archive', 'domain_history')
|
render_by_format('admin/domain_versions/archive', 'domain_history')
|
||||||
|
|
|
@ -8,35 +8,21 @@ module Admin
|
||||||
# rubocop:disable Metrics/MethodLength
|
# rubocop:disable Metrics/MethodLength
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
domains = if params[:statuses_contains]
|
domains = Domain.includes(:registrar, :registrant).joins(:registrar, :registrant)
|
||||||
Domain.includes(:registrar, :registrant).where(
|
p = params[:statuses_contains]
|
||||||
"domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
domains = domains.where('domains.statuses @> ?::varchar[]', "{#{p.join(',')}}") if p.present?
|
||||||
)
|
|
||||||
else
|
|
||||||
Domain.includes(:registrar, :registrant)
|
|
||||||
end
|
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@domains = @q.result.page(params[:page])
|
@result = @q.result.distinct
|
||||||
|
@domains = @result.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
||||||
render_by_format('admin/domains/index', 'domains')
|
render_by_format('admin/domains/index', 'domains')
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
|
||||||
|
|
||||||
def show
|
|
||||||
# Validation is needed to warn users
|
|
||||||
@domain.validate
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
|
||||||
build_associations
|
|
||||||
end
|
|
||||||
|
|
||||||
# rubocop:disable Metrics/MethodLength
|
|
||||||
def update
|
def update
|
||||||
rollback_history = @domain.json_statuses_history&.[]('admin_store_statuses_history')
|
rollback_history = @domain.json_statuses_history&.[]('admin_store_statuses_history')
|
||||||
dp = ignore_empty_statuses
|
dp = ignore_empty_statuses
|
||||||
|
@ -56,6 +42,15 @@ module Admin
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
|
def show
|
||||||
|
# Validation is needed to warn users
|
||||||
|
@domain.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
build_associations
|
||||||
|
end
|
||||||
|
|
||||||
def versions
|
def versions
|
||||||
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
||||||
@versions = @domain.versions
|
@versions = @domain.versions
|
||||||
|
|
|
@ -6,9 +6,10 @@ module Admin
|
||||||
# rubocop:disable Metrics/MethodLength
|
# rubocop:disable Metrics/MethodLength
|
||||||
def index
|
def index
|
||||||
@q = ApiLog::EppLog.ransack(PartialSearchFormatter.format(params[:q]))
|
@q = ApiLog::EppLog.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
|
@result = @q.result
|
||||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||||
|
|
||||||
@epp_logs = @q.result
|
@epp_logs = @result
|
||||||
if params[:q][:created_at_gteq].present?
|
if params[:q][:created_at_gteq].present?
|
||||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
||||||
Time.parse(params[:q][:created_at_gteq]))
|
Time.parse(params[:q][:created_at_gteq]))
|
||||||
|
|
|
@ -39,7 +39,8 @@ module Admin
|
||||||
|
|
||||||
@q = invoices.ransack(params[:q])
|
@q = invoices.ransack(params[:q])
|
||||||
@q.sorts = 'number desc' if @q.sorts.empty?
|
@q.sorts = 'number desc' if @q.sorts.empty?
|
||||||
@invoices = @q.result.page(params[:page])
|
@result = @q.result
|
||||||
|
@invoices = @result.page(params[:page])
|
||||||
@invoices = @invoices.per(params[:results_per_page]) if paginate?
|
@invoices = @invoices.per(params[:results_per_page]) if paginate?
|
||||||
|
|
||||||
render_by_format('admin/invoices/index', 'invoices')
|
render_by_format('admin/invoices/index', 'invoices')
|
||||||
|
|
|
@ -7,8 +7,8 @@ module Admin
|
||||||
def index
|
def index
|
||||||
@q = ApiLog::ReppLog.ransack(PartialSearchFormatter.format(params[:q]))
|
@q = ApiLog::ReppLog.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||||
|
@result = @q.result
|
||||||
@repp_logs = @q.result
|
@repp_logs = @result
|
||||||
if params[:q][:created_at_gteq].present?
|
if params[:q][:created_at_gteq].present?
|
||||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
||||||
Time.parse(params[:q][:created_at_gteq]))
|
Time.parse(params[:q][:created_at_gteq]))
|
||||||
|
|
|
@ -7,7 +7,8 @@ module Admin
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
domains = ReservedDomain.all.order(:name)
|
domains = ReservedDomain.all.order(:name)
|
||||||
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@domains = @q.result.page(params[:page])
|
@result = @q.result
|
||||||
|
@domains = @result.page(params[:page])
|
||||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
||||||
render_by_format('admin/reserved_domains/index', 'reserved_domains')
|
render_by_format('admin/reserved_domains/index', 'reserved_domains')
|
||||||
|
|
|
@ -16,12 +16,12 @@ class Account < ApplicationRecord
|
||||||
[id, balance, currency, registrar]
|
[id, balance, currency, registrar]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.csv_header
|
def self.csv_header
|
||||||
|
|
|
@ -25,12 +25,12 @@ class AccountActivity < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_attributes(auth_object = nil)
|
def ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def types_for_select
|
def types_for_select
|
||||||
|
|
|
@ -5,12 +5,12 @@ module ApiLog
|
||||||
# for a configuration lookup is deprecated
|
# for a configuration lookup is deprecated
|
||||||
establish_connection "api_log_#{Rails.env}".to_sym
|
establish_connection "api_log_#{Rails.env}".to_sym
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,12 +33,12 @@ class Auction < ApplicationRecord
|
||||||
where('domain ilike ?', "%#{domain_name.strip}%") if domain_name.present?
|
where('domain ilike ?', "%#{domain_name.strip}%") if domain_name.present?
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.pending(domain_name)
|
def self.pending(domain_name)
|
||||||
|
|
|
@ -10,8 +10,8 @@ class BankStatement < ApplicationRecord
|
||||||
PARTIALLY_BINDED = 'partially_binded'.freeze
|
PARTIALLY_BINDED = 'partially_binded'.freeze
|
||||||
NOT_BINDED = 'not_binded'.freeze
|
NOT_BINDED = 'not_binded'.freeze
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Cache this to database so it can be used for searching
|
# TODO: Cache this to database so it can be used for searching
|
||||||
|
|
|
@ -8,12 +8,12 @@ class BankTransaction < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)')
|
where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)')
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def binded?
|
def binded?
|
||||||
|
|
|
@ -21,8 +21,8 @@ module Billing
|
||||||
new_record? || duration_changed?
|
new_record? || duration_changed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.operation_categories
|
def self.operation_categories
|
||||||
|
|
|
@ -6,12 +6,12 @@ class BlockedDomain < ApplicationRecord
|
||||||
validates :name, domain_name: true, uniqueness: true
|
validates :name, domain_name: true, uniqueness: true
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_attributes(auth_object = nil)
|
def ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def by_domain(name)
|
def by_domain(name)
|
||||||
|
|
|
@ -183,12 +183,12 @@ class Contact < ApplicationRecord
|
||||||
#
|
#
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransackable_attributes(auth_object = nil)
|
def ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_by_query(query)
|
def search_by_query(query)
|
||||||
|
|
|
@ -21,12 +21,12 @@ class Dispute < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
Domain.find_by(name: domain_name)
|
Domain.find_by(name: domain_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.close_by_domain(domain_name)
|
def self.close_by_domain(domain_name)
|
||||||
|
|
|
@ -154,30 +154,30 @@ class Domain < ApplicationRecord
|
||||||
|
|
||||||
validates :nameservers, domain_nameserver: {
|
validates :nameservers, domain_nameserver: {
|
||||||
min: -> { Setting.ns_min_count },
|
min: -> { Setting.ns_min_count },
|
||||||
max: -> { Setting.ns_max_count }
|
max: -> { Setting.ns_max_count },
|
||||||
}
|
}
|
||||||
|
|
||||||
validates :dnskeys, object_count: {
|
validates :dnskeys, object_count: {
|
||||||
min: -> { Setting.dnskeys_min_count },
|
min: -> { Setting.dnskeys_min_count },
|
||||||
max: -> { Setting.dnskeys_max_count }
|
max: -> { Setting.dnskeys_max_count },
|
||||||
}
|
}
|
||||||
|
|
||||||
validates :admin_domain_contacts, object_count: {
|
validates :admin_domain_contacts, object_count: {
|
||||||
min: -> { Setting.admin_contacts_min_count },
|
min: -> { Setting.admin_contacts_min_count },
|
||||||
max: -> { Setting.admin_contacts_max_count }
|
max: -> { Setting.admin_contacts_max_count },
|
||||||
}
|
}
|
||||||
|
|
||||||
validates :tech_domain_contacts, object_count: {
|
validates :tech_domain_contacts, object_count: {
|
||||||
min: -> { Setting.tech_contacts_min_count },
|
min: -> { Setting.tech_contacts_min_count },
|
||||||
max: -> { Setting.tech_contacts_max_count }
|
max: -> { Setting.tech_contacts_max_count },
|
||||||
}
|
}
|
||||||
|
|
||||||
validates :nameservers, uniqueness_multi: {
|
validates :nameservers, uniqueness_multi: {
|
||||||
attribute: 'hostname'
|
attribute: 'hostname',
|
||||||
}
|
}
|
||||||
|
|
||||||
validates :dnskeys, uniqueness_multi: {
|
validates :dnskeys, uniqueness_multi: {
|
||||||
attribute: 'public_key'
|
attribute: 'public_key',
|
||||||
}
|
}
|
||||||
|
|
||||||
validate :validate_nameserver_ips
|
validate :validate_nameserver_ips
|
||||||
|
@ -225,7 +225,7 @@ class Domain < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def delegated_nameservers
|
def delegated_nameservers
|
||||||
nameservers.select { |x| !x.hostname.end_with?(name) }
|
nameservers.reject { |x| x.hostname.end_with?(name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def extension_update_prohibited?
|
def extension_update_prohibited?
|
||||||
|
@ -245,12 +245,12 @@ class Domain < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransackable_attributes(auth_object = nil)
|
def ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def nameserver_required?
|
def nameserver_required?
|
||||||
|
@ -604,17 +604,17 @@ class Domain < ApplicationRecord
|
||||||
|
|
||||||
# check for deleted status
|
# check for deleted status
|
||||||
statuses.each do |s|
|
statuses.each do |s|
|
||||||
unless update.include? s
|
next if update.include? s
|
||||||
case s
|
|
||||||
when DomainStatus::PENDING_DELETE
|
case s
|
||||||
self.delete_date = nil
|
when DomainStatus::PENDING_DELETE
|
||||||
when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set
|
self.delete_date = nil
|
||||||
self.outzone_at = Time.zone.now if force_delete_scheduled?
|
when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set
|
||||||
when DomainStatus::EXPIRED # removal causes server hold to set
|
self.outzone_at = Time.zone.now if force_delete_scheduled?
|
||||||
self.outzone_at = expire_time + 15.day
|
when DomainStatus::EXPIRED # removal causes server hold to set
|
||||||
when DomainStatus::SERVER_HOLD # removal causes server hold to set
|
self.outzone_at = expire_time + 15.day
|
||||||
self.outzone_at = nil
|
when DomainStatus::SERVER_HOLD # removal causes server hold to set
|
||||||
end
|
self.outzone_at = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -626,7 +626,7 @@ class Domain < ApplicationRecord
|
||||||
def set_pending_update
|
def set_pending_update
|
||||||
if pending_update_prohibited?
|
if pending_update_prohibited?
|
||||||
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_UPDATE not allowed to set. [#{statuses}]"
|
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_UPDATE not allowed to set. [#{statuses}]"
|
||||||
return nil
|
return
|
||||||
end
|
end
|
||||||
statuses << DomainStatus::PENDING_UPDATE
|
statuses << DomainStatus::PENDING_UPDATE
|
||||||
end
|
end
|
||||||
|
@ -655,7 +655,7 @@ class Domain < ApplicationRecord
|
||||||
def set_pending_delete
|
def set_pending_delete
|
||||||
if pending_delete_prohibited?
|
if pending_delete_prohibited?
|
||||||
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_DELETE not allowed to set. [#{statuses}]"
|
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_DELETE not allowed to set. [#{statuses}]"
|
||||||
return nil
|
return
|
||||||
end
|
end
|
||||||
statuses << DomainStatus::PENDING_DELETE
|
statuses << DomainStatus::PENDING_DELETE
|
||||||
end
|
end
|
||||||
|
@ -755,12 +755,17 @@ class Domain < ApplicationRecord
|
||||||
def as_csv_row
|
def as_csv_row
|
||||||
[
|
[
|
||||||
name,
|
name,
|
||||||
registrant_name,
|
registrant_info[0],
|
||||||
|
registrant_info[1],
|
||||||
|
registrant_info[2],
|
||||||
|
registrant_info[3],
|
||||||
valid_to.to_formatted_s(:db),
|
valid_to.to_formatted_s(:db),
|
||||||
registrar,
|
registrar,
|
||||||
created_at.to_formatted_s(:db),
|
created_at.to_formatted_s(:db),
|
||||||
statuses,
|
statuses,
|
||||||
contacts.pluck(:code),
|
admin_contacts.map { |c| "#{c.name}, #{c.code}, #{ApplicationController.helpers.ident_for(c)}" },
|
||||||
|
tech_contacts.map { |c| "#{c.name}, #{c.code}, #{ApplicationController.helpers.ident_for(c)}" },
|
||||||
|
nameservers.pluck(:hostname),
|
||||||
force_delete_date,
|
force_delete_date,
|
||||||
force_delete_data,
|
force_delete_data,
|
||||||
]
|
]
|
||||||
|
@ -772,21 +777,31 @@ class Domain < ApplicationRecord
|
||||||
generator.to_pdf
|
generator.to_pdf
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant_name
|
def registrant_info
|
||||||
return registrant.name if registrant
|
if registrant
|
||||||
|
return [registrant.name, registrant.ident, registrant.ident_country_code,
|
||||||
|
registrant.ident_type]
|
||||||
|
end
|
||||||
|
|
||||||
ver = Version::ContactVersion.where(item_id: registrant_id).last
|
ver = Version::ContactVersion.where(item_id: registrant_id).last
|
||||||
contact = Contact.all_versions_for([registrant_id], created_at).first
|
contact = Contact.all_versions_for([registrant_id], created_at).first
|
||||||
|
|
||||||
contact = ObjectVersionsParser.new(ver).parse if contact.nil? && ver
|
contact = ObjectVersionsParser.new(ver).parse if contact.nil? && ver
|
||||||
|
|
||||||
contact.try(:name) || 'Deleted'
|
[contact.try(:name), contact.try(:ident), contact.try(:ident_country_code),
|
||||||
|
contact.try(:ident_type)] || ['Deleted']
|
||||||
|
end
|
||||||
|
|
||||||
|
def registrant_ident_info
|
||||||
|
return ApplicationController.helpers.ident_for(registrant) if registrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.csv_header
|
def self.csv_header
|
||||||
[
|
[
|
||||||
'Domain', 'Registrant', 'Valid to', 'Registrar', 'Created at',
|
'Domain', 'Registrant name', 'Registrant ident', 'Registrant ident country code',
|
||||||
'Statuses', 'Contacts code', 'Force delete date', 'Force delete data'
|
'Registrant ident type', 'Valid to', 'Registrar', 'Created at',
|
||||||
|
'Statuses', 'Admin. contacts', 'Tech. contacts', 'Nameservers', 'Force delete date',
|
||||||
|
'Force delete data'
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -808,7 +823,7 @@ class Domain < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.uses_zone?(zone)
|
def self.uses_zone?(zone)
|
||||||
exists?(["name ILIKE ?", "%.#{zone.origin}"])
|
exists?(['name ILIKE ?', "%.#{zone.origin}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.swap_elements(array, indexes)
|
def self.swap_elements(array, indexes)
|
||||||
|
|
|
@ -144,12 +144,12 @@ class Invoice < ApplicationRecord
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.csv_header
|
def self.csv_header
|
||||||
|
|
|
@ -86,6 +86,10 @@ class Nameserver < ApplicationRecord
|
||||||
def hostnames
|
def hostnames
|
||||||
pluck(:hostname)
|
pluck(:hostname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ransackable_attributes(*)
|
||||||
|
authorizable_ransackable_attributes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -51,6 +51,14 @@ class Registrar < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
self.ignored_columns = %w[legacy_id]
|
self.ignored_columns = %w[legacy_id]
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
def ransackable_associations(*)
|
||||||
|
authorizable_ransackable_associations
|
||||||
|
end
|
||||||
|
|
||||||
|
def ransackable_attributes(*)
|
||||||
|
authorizable_ransackable_attributes
|
||||||
|
end
|
||||||
|
|
||||||
def ordered
|
def ordered
|
||||||
order(name: :asc)
|
order(name: :asc)
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,12 +13,12 @@ class ReservedDomain < ApplicationRecord
|
||||||
self.ignored_columns = %w[legacy_id]
|
self.ignored_columns = %w[legacy_id]
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_attributes(auth_object = nil)
|
def ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def pw_for(domain_name)
|
def pw_for(domain_name)
|
||||||
|
|
|
@ -17,12 +17,12 @@ class Version::ContactVersion < PaperTrail::Version
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.csv_header
|
def self.csv_header
|
||||||
|
|
|
@ -11,19 +11,19 @@ class Version::DomainVersion < PaperTrail::Version
|
||||||
|
|
||||||
[
|
[
|
||||||
domain.name,
|
domain.name,
|
||||||
domain.registrant_name,
|
domain.registrant_info[0],
|
||||||
domain.registrar,
|
domain.registrar,
|
||||||
event,
|
event,
|
||||||
created_at.to_formatted_s(:db)
|
created_at.to_formatted_s(:db),
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
def self.ransackable_associations(*)
|
||||||
super
|
authorizable_ransackable_associations
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ransackable_associations(auth_object = nil)
|
def self.ransackable_attributes(*)
|
||||||
super
|
authorizable_ransackable_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.was_contact_linked?(contact_id)
|
def self.was_contact_linked?(contact_id)
|
||||||
|
|
|
@ -3,11 +3,23 @@ class PartialSearchFormatter
|
||||||
search_params = params.deep_dup
|
search_params = params.deep_dup
|
||||||
|
|
||||||
search_params.each do |key, value|
|
search_params.each do |key, value|
|
||||||
next unless key.include?('matches') && value.present?
|
next unless should_format?(key, value)
|
||||||
|
|
||||||
search_params[key] = "%#{value}%"
|
search_params[key] = format_value(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
search_params
|
search_params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.should_format?(key, value)
|
||||||
|
key.include?('matches') && value.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.format_value(value)
|
||||||
|
if value =~ /\A\*.*\*\z/
|
||||||
|
value.gsub(/\A\*|\*\z/, '')
|
||||||
|
else
|
||||||
|
"%#{value}%"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ class DomainNameValidator < ActiveModel::EachValidator
|
||||||
# rubocop:disable Metrics/LineLength
|
# rubocop:disable Metrics/LineLength
|
||||||
def validate_each(record, attribute, value)
|
def validate_each(record, attribute, value)
|
||||||
if !self.class.validate_format(value)
|
if !self.class.validate_format(value)
|
||||||
record.errors[attribute] << (options[:message] || record.errors.generate_message(attribute, :invalid))
|
record.errors.add(attribute, options[:message] || record.errors.generate_message(attribute, :invalid))
|
||||||
elsif !self.class.validate_blocked(value)
|
elsif !self.class.validate_blocked(value)
|
||||||
record.errors.add(:base, :domain_name_blocked)
|
record.errors.add(:base, :domain_name_blocked)
|
||||||
end
|
end
|
||||||
|
@ -12,6 +12,7 @@ class DomainNameValidator < ActiveModel::EachValidator
|
||||||
class << self
|
class << self
|
||||||
def validate_format(value)
|
def validate_format(value)
|
||||||
return true unless value
|
return true unless value
|
||||||
|
|
||||||
value = value.mb_chars.downcase.strip
|
value = value.mb_chars.downcase.strip
|
||||||
|
|
||||||
origins = DNS::Zone.origins
|
origins = DNS::Zone.origins
|
||||||
|
@ -25,6 +26,7 @@ class DomainNameValidator < ActiveModel::EachValidator
|
||||||
if value[2] == '-' && value[3] == '-'
|
if value[2] == '-' && value[3] == '-'
|
||||||
regexp = /\Axn--[a-zA-Z0-9-]{0,59}\.#{general_domains}\z/
|
regexp = /\Axn--[a-zA-Z0-9-]{0,59}\.#{general_domains}\z/
|
||||||
return false unless value.match?(regexp)
|
return false unless value.match?(regexp)
|
||||||
|
|
||||||
value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip
|
value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to domain, admin_domain_path(domain) %></td>
|
<td style="word-break:break-all;"><%= link_to domain, admin_domain_path(domain) %></td>
|
||||||
<td><%= link_to domain.registrant, admin_contact_path(domain.registrant) %></td>
|
<td><%= link_to domain.registrant, admin_contact_path(domain.registrant) %></td>
|
||||||
<td><%= l domain.expire_time %></td>
|
<td><%= l domain.expire_time %></td>
|
||||||
<td><%= link_to domain.registrar, admin_registrar_path(domain.registrar) %></td>
|
<td><%= link_to domain.registrar, admin_registrar_path(domain.registrar) %></td>
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5">Tip: Use format *text* for exact match!</div>
|
||||||
<div class="col-md-3"></div>
|
<div class="col-md-3"></div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
4
test/fixtures/files/domains.csv
vendored
4
test/fixtures/files/domains.csv
vendored
|
@ -1,2 +1,2 @@
|
||||||
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Contacts code,Force delete date,Force delete data
|
Domain,Registrant name,Registrant ident,Registrant ident country code,Registrant ident type,Valid to,Registrar,Created at,Statuses,Admin. contacts,Tech. contacts,Nameservers,Force delete date,Force delete data
|
||||||
metro.test,Jack,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""jack-001"", ""jack-001""]",,
|
metro.test,Jack,12345678,US,org,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""Jack, jack-001, 12345678 [US org]""]","[""Jack, jack-001, 12345678 [US org]""]","[""ns1.bestnames.test""]",,
|
||||||
|
|
|
Loading…
Add table
Add a link
Reference in a new issue