111864739-legaldocs_for_contacts

This commit is contained in:
Stas 2016-02-01 18:08:44 +02:00
parent 7f9e1e0c9c
commit f087a00bef
2 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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