mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Merge pull request #1817 from internetee/1764-registrar-bulk-admin-change
Domain admin contacts bulk change feature
This commit is contained in:
commit
a46b04856f
22 changed files with 524 additions and 136 deletions
|
@ -1,2 +1,26 @@
|
|||
class AdminDomainContact < DomainContact
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def self.replace(current_contact, new_contact)
|
||||
affected_domains = []
|
||||
skipped_domains = []
|
||||
admin_contacts = where(contact: current_contact)
|
||||
|
||||
admin_contacts.each do |admin_contact|
|
||||
if admin_contact.domain.bulk_update_prohibited?
|
||||
skipped_domains << admin_contact.domain.name
|
||||
next
|
||||
end
|
||||
begin
|
||||
admin_contact.contact = new_contact
|
||||
admin_contact.save!
|
||||
affected_domains << admin_contact.domain.name
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
skipped_domains << admin_contact.domain.name
|
||||
end
|
||||
end
|
||||
[affected_domains.sort, skipped_domains.sort]
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
end
|
||||
|
|
|
@ -11,6 +11,13 @@ module Concerns::Contact::Identical
|
|||
ident_country_code
|
||||
org_name
|
||||
]
|
||||
|
||||
IDENTICAL_ATTRIBUTES = %w[
|
||||
ident
|
||||
ident_type
|
||||
ident_country_code
|
||||
].freeze
|
||||
|
||||
private_constant :IDENTIFIABLE_ATTRIBUTES
|
||||
|
||||
def identical(registrar)
|
||||
|
@ -20,6 +27,12 @@ module Concerns::Contact::Identical
|
|||
.where.not(id: id).take
|
||||
end
|
||||
|
||||
def identical_to?(contact)
|
||||
IDENTICAL_ATTRIBUTES.all? do |attribute|
|
||||
attributes[attribute] == contact.attributes[attribute]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def identifiable_hash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue