mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Refactor
This commit is contained in:
parent
8b8a71c4d1
commit
f8c48a7456
3 changed files with 9 additions and 11 deletions
|
@ -32,10 +32,6 @@ class Contact < ActiveRecord::Base
|
|||
"birthday" #Birthday date
|
||||
]
|
||||
|
||||
CONTACT_TYPE_TECH = 'tech'
|
||||
CONTACT_TYPE_ADMIN = 'admin'
|
||||
CONTACT_TYPES = [CONTACT_TYPE_TECH, CONTACT_TYPE_ADMIN]
|
||||
|
||||
def ident_must_be_valid
|
||||
#TODO Ident can also be passport number or company registry code.
|
||||
#so have to make changes to validations (and doc/schema) accordingly
|
||||
|
@ -91,7 +87,7 @@ class Contact < ActiveRecord::Base
|
|||
'2302' => [ #Object exists
|
||||
[:code, :epp_id_taken]
|
||||
],
|
||||
'2303' => #Object does not exist
|
||||
'2303' => #Object does not exist
|
||||
[:not_found, :epp_obj_does_not_exist],
|
||||
'2305' => [ #Association exists
|
||||
[:domains, :exist]
|
||||
|
|
|
@ -16,11 +16,11 @@ class Domain < ActiveRecord::Base
|
|||
has_many :domain_contacts
|
||||
|
||||
has_many :tech_contacts, -> {
|
||||
where(domain_contacts: {contact_type: Contact::CONTACT_TYPE_TECH})
|
||||
where(domain_contacts: {contact_type: DomainContact::TECH})
|
||||
}, through: :domain_contacts, source: :contact
|
||||
|
||||
has_many :admin_contacts, -> {
|
||||
where(domain_contacts: {contact_type: Contact::CONTACT_TYPE_ADMIN})
|
||||
where(domain_contacts: {contact_type: DomainContact::ADMIN})
|
||||
}, through: :domain_contacts, source: :contact
|
||||
|
||||
has_and_belongs_to_many :nameservers
|
||||
|
@ -108,10 +108,10 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
if owner_contact
|
||||
attach_contact(Contact::CONTACT_TYPE_TECH, owner_contact) if tech_contacts.empty?
|
||||
attach_contact(DomainContact::TECH, owner_contact) if tech_contacts.empty?
|
||||
|
||||
if owner_contact.citizen?
|
||||
attach_contact(Contact::CONTACT_TYPE_ADMIN, owner_contact) if admin_contacts.empty?
|
||||
attach_contact(DomainContact::ADMIN, owner_contact) if admin_contacts.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -290,7 +290,7 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
def parse_contacts_from_frame(parsed_frame)
|
||||
res = {}
|
||||
Contact::CONTACT_TYPES.each do |ct|
|
||||
DomainContact::TYPES.each do |ct|
|
||||
res[ct.to_sym] ||= []
|
||||
parsed_frame.css("contact[type='#{ct}']").each do |x|
|
||||
res[ct.to_sym] << Hash.from_xml(x.to_s).with_indifferent_access
|
||||
|
|
|
@ -2,5 +2,7 @@ class DomainContact < ActiveRecord::Base
|
|||
belongs_to :contact
|
||||
belongs_to :domain
|
||||
|
||||
scope :tech, -> {where(contact_type: :tech)}
|
||||
TECH = 'tech'
|
||||
ADMIN = 'admin'
|
||||
TYPES = [TECH, ADMIN]
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue