Add owner to technical and admin contact when no other contacts are specified

This commit is contained in:
Martin Lensment 2014-07-31 12:09:07 +03:00
parent 62b3ff6fc7
commit 3c3a8bfb47
3 changed files with 31 additions and 5 deletions

View file

@ -36,12 +36,23 @@ class Domain < ActiveRecord::Base
def attach_contacts(contacts)
contacts.each do |k, v|
v.each do |x|
domain_contacts.create(
contact: Contact.find_by(code: x[:contact]),
contact_type: k
)
attach_contact(k, Contact.find_by(code: x[:contact]))
end
end
if owner_contact.citizen?
attach_contact(Contact::CONTACT_TYPE_TECH, owner_contact) if tech_contacts.empty?
attach_contact(Contact::CONTACT_TYPE_ADMIN, owner_contact) if admin_contacts.empty?
end
true
end
def attach_contact(type, contact)
domain_contacts.create(
contact: contact,
contact_type: type
)
end
class << self