diff --git a/app/models/contact.rb b/app/models/contact.rb index ccc44851d..558e930d9 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -2,6 +2,7 @@ class Contact < ActiveRecord::Base include Versions # version/contact_version.rb include EppErrors include UserEvents + has_paper_trail class_name: "ContactVersion", meta: { children: :children_log } belongs_to :registrar has_many :domain_contacts @@ -9,6 +10,8 @@ class Contact < ActiveRecord::Base has_many :legal_documents, as: :documentable has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # when contant is registrant + attr_accessor :legal_document_id + # TODO: remove later has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy @@ -499,6 +502,12 @@ class Contact < ActiveRecord::Base def update_related_whois_records related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).try(:save) } - end + end + + def children_log + log = HashWithIndifferentAccess.new + log[:legal_documents]= [legal_document_id] + log + end end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index f4773f732..6df2e7b4d 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -38,7 +38,9 @@ class Epp::Contact < Contact legal_frame = f.css('legalDocument').first if legal_frame.present? - at[:legal_documents_attributes] = legal_document_attrs(legal_frame) + doc = legal_document_attrs(legal_frame) + self.legal_document_id = doc.id if doc.id + at[:legal_documents_attributes] = doc end at.merge!(ident_attrs(f.css('ident').first)) if new_record at