mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Refactor RegistrantUser class
* Extract frequently used country_code and ident methods * Refactor domain query * Add contact query method * Add adminstrated_domains query method. Name will most likely change in the future developments * Change registry locks integration test name
This commit is contained in:
parent
9f7fc47f19
commit
9623e2fb97
6 changed files with 95 additions and 55 deletions
|
@ -8,16 +8,30 @@ class RegistrantUser < User
|
|||
delegate :can?, :cannot?, to: :ability
|
||||
|
||||
def ident
|
||||
registrant_ident.to_s.split("-").last
|
||||
registrant_ident.to_s.split('-').last
|
||||
end
|
||||
|
||||
def country_code
|
||||
registrant_ident.to_s.split('-').first
|
||||
end
|
||||
|
||||
def domains
|
||||
ident_cc, ident = registrant_ident.to_s.split '-'
|
||||
Domain.includes(:registrar, :registrant).where(contacts: {
|
||||
ident_type: 'priv',
|
||||
ident: ident, #identity_code,
|
||||
ident_country_code: ident_cc #country_code
|
||||
})
|
||||
Domain.includes(:registrar, :registrant).where(
|
||||
contacts: {
|
||||
ident_type: 'priv',
|
||||
ident: ident,
|
||||
ident_country_code: country_code
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def contacts
|
||||
Contact.where(ident_type: 'priv', ident: ident, ident_country_code: country_code)
|
||||
end
|
||||
|
||||
def administrated_domains
|
||||
Domain.joins(:domain_contacts)
|
||||
.where(domain_contacts: { contact_id: contacts, type: AdminDomainContact })
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue