mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 01:36:02 +02:00
Exclude tech from default domain query
This commit is contained in:
parent
d07b6a9c7b
commit
1bb975c0cc
3 changed files with 17 additions and 4 deletions
|
@ -42,7 +42,7 @@ module Api
|
||||||
private
|
private
|
||||||
|
|
||||||
def current_user_domains
|
def current_user_domains
|
||||||
current_registrant_user.domains
|
current_registrant_user.domains(admin: params[:tech] != 'true')
|
||||||
rescue CompanyRegister::NotAvailableError
|
rescue CompanyRegister::NotAvailableError
|
||||||
current_registrant_user.direct_domains
|
current_registrant_user.direct_domains
|
||||||
end
|
end
|
||||||
|
|
|
@ -198,6 +198,15 @@ class Domain < ApplicationRecord
|
||||||
Setting.nameserver_required
|
Setting.nameserver_required
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def registrant_user_admin_registrant_domains(registrant_user)
|
||||||
|
companies = Contact.registrant_user_company_contacts(registrant_user)
|
||||||
|
from(
|
||||||
|
"(#{registrant_user_administered_domains(registrant_user).to_sql} UNION " \
|
||||||
|
"#{registrant_user_company_registrant(registrant_user).to_sql} UNION " \
|
||||||
|
"#{registrant_user_domains_company(companies, except_tech: true).to_sql}) AS domains"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def registrant_user_domains(registrant_user)
|
def registrant_user_domains(registrant_user)
|
||||||
from(
|
from(
|
||||||
"(#{registrant_user_domains_by_registrant(registrant_user).to_sql} UNION " \
|
"(#{registrant_user_domains_by_registrant(registrant_user).to_sql} UNION " \
|
||||||
|
@ -255,8 +264,10 @@ class Domain < ApplicationRecord
|
||||||
where(registrant: companies)
|
where(registrant: companies)
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant_user_domains_company(companies)
|
def registrant_user_domains_company(companies, except_tech: false)
|
||||||
joins(:domain_contacts).where(domain_contacts: { contact: companies })
|
request = { contact: companies }
|
||||||
|
request[:type] = [AdminDomainContact.name] if except_tech
|
||||||
|
joins(:domain_contacts).where(domain_contacts: request)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,9 @@ class RegistrantUser < User
|
||||||
Contact.registrant_user_direct_contacts(self)
|
Contact.registrant_user_direct_contacts(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def domains
|
def domains(admin: false)
|
||||||
|
return Domain.registrant_user_admin_registrant_domains(self) if admin
|
||||||
|
|
||||||
Domain.registrant_user_domains(self)
|
Domain.registrant_user_domains(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue