mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 19:48:28 +02:00
Refactor to nameserver
This commit is contained in:
parent
bc7c5d648b
commit
4ea7a7ad57
3 changed files with 19 additions and 10 deletions
|
@ -37,8 +37,6 @@ class Domain < ActiveRecord::Base
|
|||
delegate :phone, to: :owner_contact, prefix: true
|
||||
delegate :name, to: :registrar, prefix: true
|
||||
|
||||
before_validation :downcase_attributes
|
||||
|
||||
before_create :generate_auth_info
|
||||
before_create :set_validity_dates
|
||||
after_create :attach_default_contacts
|
||||
|
@ -72,14 +70,6 @@ class Domain < ActiveRecord::Base
|
|||
self[:name_dirty] = value
|
||||
end
|
||||
|
||||
def downcase_attributes
|
||||
nameservers.each do |x|
|
||||
x.hostname = x.hostname.try(:strip).try(:downcase)
|
||||
x.ipv4 = x.ipv4.try(:strip)
|
||||
x.ipv6 = x.ipv6.try(:strip).try(:upcase)
|
||||
end
|
||||
end
|
||||
|
||||
def owner_contact_typeahead
|
||||
@owner_contact_typeahead || owner_contact.try(:name) || nil
|
||||
end
|
||||
|
|
|
@ -13,6 +13,8 @@ class Nameserver < ActiveRecord::Base
|
|||
# archiving
|
||||
has_paper_trail class_name: 'NameserverVersion'
|
||||
|
||||
before_validation :normalize_attributes
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2302' => [
|
||||
|
@ -29,6 +31,12 @@ class Nameserver < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
def normalize_attributes
|
||||
self.hostname = hostname.try(:strip).try(:downcase)
|
||||
self.ipv4 = ipv4.try(:strip)
|
||||
self.ipv6 = ipv6.try(:strip).try(:upcase)
|
||||
end
|
||||
|
||||
def to_s
|
||||
hostname
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue