mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 11:38:30 +02:00
Prevent creating multiple new contacts
This commit is contained in:
parent
565e20b5dc
commit
e5889e87e1
2 changed files with 88 additions and 8 deletions
|
@ -417,7 +417,10 @@ class Epp::Domain < Domain
|
|||
owner_contact.update_column(:registrar_id, current_user.registrar_id)
|
||||
end
|
||||
|
||||
copied_ids = []
|
||||
contacts.each do |c|
|
||||
next if copied_ids.include?(c.id)
|
||||
|
||||
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', c.id, id).count > 0
|
||||
if c.domains.count > 1 || is_other_domains_contact
|
||||
# create contact
|
||||
|
@ -427,7 +430,8 @@ class Epp::Domain < Domain
|
|||
oc.registrar_id = current_user.registrar_id
|
||||
oc.save!
|
||||
|
||||
domain_contacts.update_all({ contact_id: oc.id })
|
||||
domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id })
|
||||
copied_ids << c.id
|
||||
else
|
||||
# transfer contact
|
||||
c.update_column(:registrar_id, current_user.registrar_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue