mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 17:23:34 +02:00
Merge pull request #107 from internetee/105842700-registrants_portal
105842700 registrants portal
This commit is contained in:
commit
71e3db611b
18 changed files with 126 additions and 242 deletions
|
@ -22,17 +22,26 @@ class BusinessRegistryCache < ActiveRecord::Base
|
|||
|
||||
# 1. load domains by business
|
||||
# 2. load domains by person
|
||||
def associated_domains
|
||||
domains = []
|
||||
|
||||
def associated_contacts
|
||||
contact_ids = Contact.where(ident_type: 'org', ident: associated_businesses, ident_country_code: 'EE').pluck(:id)
|
||||
contact_ids += Contact.where(ident_type: 'priv', ident: ident, ident_country_code: ident_country_code).pluck(:id)
|
||||
contact_ids
|
||||
end
|
||||
|
||||
def associated_domain_ids
|
||||
domain_ids = []
|
||||
|
||||
contact_ids = associated_contacts
|
||||
|
||||
unless contact_ids.blank?
|
||||
domains = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
|
||||
domain_ids = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
|
||||
end
|
||||
|
||||
Domain.includes(:registrar, :registrant).where(id: domains)
|
||||
domain_ids
|
||||
end
|
||||
|
||||
def associated_domains
|
||||
Domain.includes(:registrar, :registrant).where(id: associated_domain_ids)
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
|
@ -415,7 +415,10 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
|
||||
# fetch domains
|
||||
domains = Domain.where("domains.id IN (#{filter_sql})").includes(:registrar).page(page).per(per)
|
||||
domains = Domain.where("domains.id IN (#{filter_sql})")
|
||||
domains = domains.where("domains.id" => params[:leave_domains]) if params[:leave_domains]
|
||||
domains = domains.includes(:registrar).page(page).per(per)
|
||||
|
||||
if sorts.first == "registrar_name".freeze
|
||||
# using small rails hack to generate outer join
|
||||
domains = domains.includes(:registrar).where.not(registrars: {id: nil}).order("registrars.name #{order} NULLS LAST")
|
||||
|
@ -434,6 +437,30 @@ class Contact < ActiveRecord::Base
|
|||
domains
|
||||
end
|
||||
|
||||
def all_registrant_domains(page: nil, per: nil, params: {}, registrant: nil)
|
||||
|
||||
if registrant
|
||||
sorts = params.fetch(:sort, {}).first || []
|
||||
sort = Domain.column_names.include?(sorts.first) ? sorts.first : "valid_to"
|
||||
order = {"asc"=>"desc", "desc"=>"asc"}[sorts.second] || "desc"
|
||||
|
||||
domain_ids = DomainContact.distinct.where(contact_id: registrant.id).pluck(:domain_id)
|
||||
|
||||
domains = Domain.where(id: domain_ids).includes(:registrar).page(page).per(per)
|
||||
if sorts.first == "registrar_name".freeze
|
||||
domains = domains.includes(:registrar).where.not(registrars: {id: nil}).order("registrars.name #{order} NULLS LAST")
|
||||
else
|
||||
domains = domains.order("#{sort} #{order} NULLS LAST")
|
||||
end
|
||||
|
||||
domain_c = Hash.new([])
|
||||
registrant_domains.where(id: domains.map(&:id)).each{|d| domain_c[d.id] |= ["Registrant".freeze] }
|
||||
DomainContact.where(contact_id: id, domain_id: domains.map(&:id)).each{|d| domain_c[d.domain_id] |= [d.type] }
|
||||
domains.each{|d| d.roles = domain_c[d.id].uniq}
|
||||
domains
|
||||
end
|
||||
end
|
||||
|
||||
def set_linked
|
||||
statuses << LINKED if statuses.detect { |s| s == LINKED }.blank?
|
||||
end
|
||||
|
|
|
@ -869,6 +869,7 @@ class Epp::Domain < Domain
|
|||
ld = parsed_frame.css('legalDocument').first
|
||||
return nil unless ld
|
||||
return nil if ld.text.starts_with?(ENV['legal_documents_dir']) # escape reloading
|
||||
return nil if ld.text.starts_with?('/home/') # escape reloading
|
||||
|
||||
{
|
||||
body: ld.text,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue