mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Story#116761157 - contact statuses are generated value
This commit is contained in:
parent
105d7bf645
commit
f2c96ba145
2 changed files with 15 additions and 74 deletions
|
@ -39,29 +39,12 @@ class Epp::Domain < Domain
|
|||
|
||||
before_save :link_contacts
|
||||
def link_contacts
|
||||
# Based on bullet report
|
||||
if new_record?
|
||||
# new record does not have correct instance contacts entries thanks to epp
|
||||
unlinked_contacts = [registrant]
|
||||
unlinked_contacts << admin_domain_contacts.map(&:contact)
|
||||
unlinked_contacts << tech_domain_contacts.map(&:contact)
|
||||
unlinked_contacts.flatten!
|
||||
else
|
||||
unlinked_contacts = contacts.select { |c| !c.linked? } # speed up a bit
|
||||
end
|
||||
|
||||
unlinked_contacts.each do |uc|
|
||||
uc.domains_present = true # no need to fetch domains again
|
||||
uc.save(validate: false)
|
||||
end
|
||||
#TODO: cleanup cache if we think to cache dynamic statuses
|
||||
end
|
||||
|
||||
after_destroy :unlink_contacts
|
||||
def unlink_contacts
|
||||
contacts.each do |c|
|
||||
c.domains_present = false
|
||||
c.save(validate: false)
|
||||
end
|
||||
#TODO: cleanup cache if we think to cache dynamic statuses
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue