mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Update contact link status for new domain #2907
This commit is contained in:
parent
58249742c1
commit
6792700d11
3 changed files with 14 additions and 4 deletions
|
@ -10,12 +10,13 @@ class Domain < ActiveRecord::Base
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
belongs_to :registrant
|
belongs_to :registrant
|
||||||
|
|
||||||
has_many :domain_contacts, dependent: :destroy
|
|
||||||
has_many :admin_domain_contacts
|
has_many :admin_domain_contacts
|
||||||
accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true
|
accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true
|
||||||
has_many :tech_domain_contacts
|
has_many :tech_domain_contacts
|
||||||
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true
|
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true
|
||||||
|
|
||||||
|
# NB! contacts, admin_contacts, tech_contacts are empty for a new record
|
||||||
|
has_many :domain_contacts, dependent: :destroy
|
||||||
has_many :contacts, through: :domain_contacts, source: :contact
|
has_many :contacts, through: :domain_contacts, source: :contact
|
||||||
has_many :admin_contacts, through: :admin_domain_contacts, source: :contact
|
has_many :admin_contacts, through: :admin_domain_contacts, source: :contact
|
||||||
has_many :tech_contacts, through: :tech_domain_contacts, source: :contact
|
has_many :tech_contacts, through: :tech_domain_contacts, source: :contact
|
||||||
|
|
|
@ -17,7 +17,7 @@ class DomainContact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
return 'Tech' if type == 'TechDomainContact'
|
return 'Tech' if type == 'TechDomainContact'
|
||||||
return 'Admin' if type == 'AdminDomainContact'
|
return 'Admin' if type == 'AdminDomainContact'
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,16 @@ class Epp::Domain < Domain
|
||||||
before_save :link_contacts
|
before_save :link_contacts
|
||||||
def link_contacts
|
def link_contacts
|
||||||
# Based on bullet report
|
# Based on bullet report
|
||||||
unlinked_contacts = contacts.select { |c| !c.linked? } # speed up a bit
|
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|
|
unlinked_contacts.each do |uc|
|
||||||
uc.domains_present = true # no need to fetch domains again
|
uc.domains_present = true # no need to fetch domains again
|
||||||
uc.save(validate: false)
|
uc.save(validate: false)
|
||||||
|
@ -114,7 +123,7 @@ class Epp::Domain < Domain
|
||||||
def attach_default_contacts
|
def attach_default_contacts
|
||||||
return if registrant.blank?
|
return if registrant.blank?
|
||||||
regt = Registrant.find(registrant.id) # temp for bullet
|
regt = Registrant.find(registrant.id) # temp for bullet
|
||||||
tech_contacts << regt if tech_domain_contacts.blank?
|
tech_contacts << regt if tech_domain_contacts.blank?
|
||||||
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
|
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue