mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
34 lines
748 B
Ruby
34 lines
748 B
Ruby
class DomainContact < ActiveRecord::Base
|
|
# STI: tech_domain_contact
|
|
# STI: admin_domain_contact
|
|
include Versions # version/domain_contact_version.rb
|
|
include EppErrors
|
|
belongs_to :contact
|
|
belongs_to :domain
|
|
|
|
attr_accessor :value_typeahead
|
|
|
|
def epp_code_map
|
|
{
|
|
'2302' => [
|
|
[:contact_code_cache, :taken, { value: { obj: 'contact', val: contact_code_cache } }]
|
|
]
|
|
}
|
|
end
|
|
|
|
validates :contact, presence: true
|
|
|
|
before_save :update_contact_code_cache
|
|
def update_contact_code_cache
|
|
self.contact_code_cache = contact.code
|
|
end
|
|
|
|
after_destroy :update_contact
|
|
def update_contact
|
|
Contact.find(contact_id).save
|
|
end
|
|
|
|
def value_typeahead
|
|
@value_typeahead || contact.try(:name) || nil
|
|
end
|
|
end
|