mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Story #109367694 - refactor: move UserEvents include up, wrap method in included block, say self
This commit is contained in:
parent
b7e560aacc
commit
7b2767eb08
5 changed files with 23 additions and 22 deletions
|
@ -1,25 +1,28 @@
|
|||
module UserEvents
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# EPP requires a server defined creator ID, which should be registrar code if we have one
|
||||
def cr_id
|
||||
# try this, rebuild user for registrar before searching history? really?
|
||||
registrar = self.creator.try(:registrar)
|
||||
if registrar.present? # Did creator return a kind of User that has a registrar?
|
||||
registrar.code
|
||||
else
|
||||
if versions.first.object.nil?
|
||||
cr_registrar_id =versions.first.object_changes['registrar_id'].second
|
||||
included do
|
||||
# EPP requires a server defined creator ID, which should be registrar code if we have one
|
||||
def cr_id
|
||||
# try this, rebuild user for registrar before searching history? really?
|
||||
registrar = self.creator.try(:registrar)
|
||||
if registrar.present? # Did creator return a kind of User that has a registrar?
|
||||
registrar.code
|
||||
else
|
||||
# untested, expected never to execute
|
||||
cr_registrar_id = versions.first.object['registrar_id']
|
||||
end
|
||||
if self.versions.first.try(:object).nil?
|
||||
changes = self.versions.first.try(:object_changes)
|
||||
cr_registrar_id = changes['registrar_id'].second if changes.present?
|
||||
else
|
||||
# untested, expected never to execute
|
||||
cr_registrar_id = self.versions.first.object['registrar_id']
|
||||
end
|
||||
|
||||
if cr_registrar_id.present?
|
||||
Registrar.find(cr_registrar_id).code
|
||||
else
|
||||
# cr_id optional for domain, but required for contact; but we want something here anyway
|
||||
self.creator_str # Fallback if we failed, maybe we can find a string here
|
||||
if cr_registrar_id.present?
|
||||
Registrar.find(cr_registrar_id).code
|
||||
else
|
||||
# cr_id optional for domain, but required for contact; but we want something here anyway
|
||||
self.creator_str # Fallback if we failed, maybe we can find a string here
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
include Versions # version/contact_version.rb
|
||||
include EppErrors
|
||||
include UserEvents
|
||||
|
||||
belongs_to :registrar
|
||||
has_many :domain_contacts
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# rubocop: disable Metrics/ClassLength
|
||||
class Domain < ActiveRecord::Base
|
||||
include UserEvents
|
||||
include Versions # version/domain_version.rb
|
||||
include Statuses
|
||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||
|
|
|
@ -3,7 +3,5 @@ class ContactVersion < PaperTrail::Version
|
|||
self.table_name = :log_contacts
|
||||
self.sequence_name = :log_contacts_id_seq
|
||||
|
||||
include UserEvents
|
||||
|
||||
# scope :deleted, -> { where(event: 'destroy') }
|
||||
end
|
||||
|
|
|
@ -4,7 +4,5 @@ class DomainVersion < PaperTrail::Version
|
|||
self.table_name = :log_domains
|
||||
self.sequence_name = :log_domains_id_seq
|
||||
|
||||
include UserEvents
|
||||
|
||||
scope :deleted, -> { where(event: 'destroy') }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue