mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Add company controlled contacts to registrant API
Fix tests.
This commit is contained in:
parent
735a0e1642
commit
c4de5655e1
8 changed files with 45 additions and 35 deletions
|
@ -200,6 +200,7 @@ class Domain < ApplicationRecord
|
|||
def registrant_user_domains(registrant_user)
|
||||
from(
|
||||
"(#{registrant_user_domains_by_registrant(registrant_user).to_sql} UNION " \
|
||||
"#{registrant_user_indirect_domains(registrant_user).to_sql} UNION " \
|
||||
"#{registrant_user_domains_by_contact(registrant_user).to_sql}) AS domains"
|
||||
)
|
||||
end
|
||||
|
@ -218,6 +219,14 @@ class Domain < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
def registrant_user_indirect_domains(registrant_user)
|
||||
companies = Contact.registrant_user_company_contacts(registrant_user)
|
||||
from(
|
||||
"(#{registrant_user_company_registrant(companies).to_sql} UNION "\
|
||||
"#{registrant_user_domains_company(companies).to_sql}) AS domains"
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def registrant_user_domains_by_registrant(registrant_user)
|
||||
|
@ -240,6 +249,14 @@ class Domain < ApplicationRecord
|
|||
def registrant_user_direct_domains_by_contact(registrant_user)
|
||||
joins(:domain_contacts).where(domain_contacts: { contact_id: registrant_user.direct_contacts })
|
||||
end
|
||||
|
||||
def registrant_user_company_registrant(companies)
|
||||
where(registrant: companies)
|
||||
end
|
||||
|
||||
def registrant_user_domains_company(companies)
|
||||
joins(:domain_contacts).where(domain_contacts: { contact: companies })
|
||||
end
|
||||
end
|
||||
|
||||
def name=(value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue