Remove contact code cache from domain contacts table

This commit is contained in:
Thiago Youssef 2022-05-04 14:38:14 +03:00
parent 3852620180
commit 750bf0821c
11 changed files with 42 additions and 50 deletions

View file

@ -6,32 +6,20 @@ class DomainContact < ApplicationRecord
belongs_to :contact
belongs_to :domain
validates :contact, presence: true
after_destroy :update_contact
attr_accessor :value_typeahead
self.ignored_columns = %w[legacy_domain_id legacy_contact_id]
def epp_code_map
{
'2302' => [
[:contact_code_cache, :taken, { value: { obj: 'contact', val: contact_code_cache } }]
]
}
end
def name
return 'Tech' if type == 'TechDomainContact'
return 'Admin' if type == 'AdminDomainContact'
''
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