mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
parent
84bc0f8914
commit
53a34ee2d6
9 changed files with 94 additions and 12 deletions
18
app/models/concerns/contact/identical.rb
Normal file
18
app/models/concerns/contact/identical.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Concerns::Contact::Identical
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ATTRIBUTE_FILTER = %w[
|
||||
name
|
||||
ident
|
||||
ident_type
|
||||
ident_country_code
|
||||
phone
|
||||
email
|
||||
]
|
||||
private_constant :ATTRIBUTE_FILTER
|
||||
|
||||
def identical(registrar)
|
||||
self.class.where(attributes.slice(*ATTRIBUTE_FILTER)).where(registrar: registrar)
|
||||
.where.not(id: id).take
|
||||
end
|
||||
end
|
|
@ -7,6 +7,8 @@ module Concerns::Contact::Transferable
|
|||
end
|
||||
|
||||
def transfer(new_registrar)
|
||||
return identical(new_registrar) if identical(new_registrar)
|
||||
|
||||
new_contact = self.dup
|
||||
new_contact.registrar = new_registrar
|
||||
new_contact.original = self
|
||||
|
|
|
@ -52,7 +52,7 @@ module Concerns::Domain::Transferable
|
|||
|
||||
def transfer_registrant(new_registrar)
|
||||
return if registrant.registrar == new_registrar
|
||||
self.registrant = registrant.transfer(new_registrar)
|
||||
self.registrant = registrant.transfer(new_registrar).becomes(Registrant)
|
||||
end
|
||||
|
||||
def transfer_domain_contacts(new_registrar)
|
||||
|
|
|
@ -3,6 +3,7 @@ class Contact < ActiveRecord::Base
|
|||
include EppErrors
|
||||
include UserEvents
|
||||
include Concerns::Contact::Transferable
|
||||
include Concerns::Contact::Identical
|
||||
|
||||
belongs_to :original, class_name: self.name
|
||||
belongs_to :registrar, required: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue