mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +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
|
"birthday" #Birthday date
|
||||||
]
|
]
|
||||||
|
|
||||||
CONTACT_TYPE_TECH = 'tech'
|
|
||||||
CONTACT_TYPE_ADMIN = 'admin'
|
|
||||||
CONTACT_TYPES = [CONTACT_TYPE_TECH, CONTACT_TYPE_ADMIN]
|
|
||||||
|
|
||||||
def ident_must_be_valid
|
def ident_must_be_valid
|
||||||
#TODO Ident can also be passport number or company registry code.
|
#TODO Ident can also be passport number or company registry code.
|
||||||
#so have to make changes to validations (and doc/schema) accordingly
|
#so have to make changes to validations (and doc/schema) accordingly
|
||||||
|
|
|
@ -16,11 +16,11 @@ class Domain < ActiveRecord::Base
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
|
|
||||||
has_many :tech_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
|
}, through: :domain_contacts, source: :contact
|
||||||
|
|
||||||
has_many :admin_contacts, -> {
|
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
|
}, through: :domain_contacts, source: :contact
|
||||||
|
|
||||||
has_and_belongs_to_many :nameservers
|
has_and_belongs_to_many :nameservers
|
||||||
|
@ -108,10 +108,10 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
if owner_contact
|
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?
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -290,7 +290,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def parse_contacts_from_frame(parsed_frame)
|
def parse_contacts_from_frame(parsed_frame)
|
||||||
res = {}
|
res = {}
|
||||||
Contact::CONTACT_TYPES.each do |ct|
|
DomainContact::TYPES.each do |ct|
|
||||||
res[ct.to_sym] ||= []
|
res[ct.to_sym] ||= []
|
||||||
parsed_frame.css("contact[type='#{ct}']").each do |x|
|
parsed_frame.css("contact[type='#{ct}']").each do |x|
|
||||||
res[ct.to_sym] << Hash.from_xml(x.to_s).with_indifferent_access
|
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 :contact
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
|
|
||||||
scope :tech, -> {where(contact_type: :tech)}
|
TECH = 'tech'
|
||||||
|
ADMIN = 'admin'
|
||||||
|
TYPES = [TECH, ADMIN]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue