Merge pull request #780 from internetee/registry-662

Enable domain contact replacement
This commit is contained in:
Timo Võhmar 2018-06-06 15:39:24 +03:00 committed by GitHub
commit 157b383738
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 708 additions and 2780 deletions

View file

@ -1,2 +1,23 @@
class TechDomainContact < DomainContact
# Audit log is needed, therefore no raw SQL
def self.replace(current_contact, new_contact)
affected_domains = []
skipped_domains = []
tech_contacts = where(contact: current_contact)
transaction do
tech_contacts.each do |tech_contact|
if tech_contact.domain.discarded?
skipped_domains << tech_contact.domain.name
next
end
tech_contact.contact = new_contact
tech_contact.save!
affected_domains << tech_contact.domain.name
end
end
return affected_domains.sort, skipped_domains.sort
end
end