mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 04:07:33 +02:00
Get admin/registrant domains when company registry is down
This commit is contained in:
parent
1bb975c0cc
commit
419396f5b4
3 changed files with 16 additions and 4 deletions
|
@ -44,7 +44,7 @@ module Api
|
|||
def current_user_domains
|
||||
current_registrant_user.domains(admin: params[:tech] != 'true')
|
||||
rescue CompanyRegister::NotAvailableError
|
||||
current_registrant_user.direct_domains
|
||||
current_registrant_user.direct_domains(admin: params[:tech] != 'true')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -207,6 +207,14 @@ class Domain < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
def registrant_user_direct_admin_registrant_domains(registrant_user)
|
||||
from(
|
||||
"(#{registrant_user_direct_domains_by_registrant(registrant_user).to_sql} UNION " \
|
||||
"#{registrant_user_direct_domains_by_contact(registrant_user,
|
||||
except_tech: true).to_sql}) AS domains"
|
||||
)
|
||||
end
|
||||
|
||||
def registrant_user_domains(registrant_user)
|
||||
from(
|
||||
"(#{registrant_user_domains_by_registrant(registrant_user).to_sql} UNION " \
|
||||
|
@ -256,8 +264,10 @@ class Domain < ApplicationRecord
|
|||
where(registrant: registrant_user.direct_contacts)
|
||||
end
|
||||
|
||||
def registrant_user_direct_domains_by_contact(registrant_user)
|
||||
joins(:domain_contacts).where(domain_contacts: { contact_id: registrant_user.direct_contacts })
|
||||
def registrant_user_direct_domains_by_contact(registrant_user, except_tech: false)
|
||||
request = { contact_id: registrant_user.direct_contacts }
|
||||
request[:type] = [AdminDomainContact.name] if except_tech
|
||||
joins(:domain_contacts).where(domain_contacts: request)
|
||||
end
|
||||
|
||||
def registrant_user_company_registrant(companies)
|
||||
|
|
|
@ -36,7 +36,9 @@ class RegistrantUser < User
|
|||
Domain.registrant_user_domains(self)
|
||||
end
|
||||
|
||||
def direct_domains
|
||||
def direct_domains(admin: false)
|
||||
return Domain.registrant_user_direct_admin_registrant_domains(self) if admin
|
||||
|
||||
Domain.registrant_user_direct_domains(self)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue