mirror of
https://github.com/internetee/registry.git
synced 2025-07-06 11:13:27 +02:00
Story#114471339 - change order when legal docs are saved into DB
This commit is contained in:
parent
6ebcaf69d0
commit
7a659da6a3
2 changed files with 25 additions and 10 deletions
|
@ -227,14 +227,22 @@ class Epp::Contact < Contact
|
|||
end
|
||||
|
||||
def add_legal_file_to_new frame
|
||||
if doc = attach_legal_document(parse_legal_document_from_frame(frame))
|
||||
raise ActiveRecord::Rollback if doc && doc.id.nil?
|
||||
legal_document_data = Epp::Contact.parse_legal_document_from_frame(frame)
|
||||
return unless legal_document_data
|
||||
|
||||
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
|
||||
self.legal_document_id = doc.id
|
||||
end
|
||||
doc = LegalDocument.create(
|
||||
documentable_type: Contact,
|
||||
document_type: legal_document_data[:type],
|
||||
body: legal_document_data[:body]
|
||||
)
|
||||
raise ActiveRecord::Rollback if doc && doc.id.nil?
|
||||
self.legal_documents = [doc]
|
||||
|
||||
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
|
||||
self.legal_document_id = doc.id
|
||||
end
|
||||
|
||||
|
||||
def parse_legal_document_from_frame frame
|
||||
ld = frame.css('legalDocument').first
|
||||
return nil unless ld
|
||||
|
|
|
@ -202,12 +202,19 @@ class Epp::Domain < Domain
|
|||
# Adding legal doc to domain and
|
||||
# if something goes wrong - raise Rollback error
|
||||
def add_legal_file_to_new frame
|
||||
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
|
||||
raise ActiveRecord::Rollback if doc && doc.id.nil?
|
||||
legal_document_data = Epp::Domain.parse_legal_document_from_frame(frame)
|
||||
return unless legal_document_data
|
||||
|
||||
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
|
||||
self.legal_document_id = doc.id
|
||||
end
|
||||
doc = LegalDocument.create(
|
||||
documentable_type: Domain,
|
||||
document_type: legal_document_data[:type],
|
||||
body: legal_document_data[:body]
|
||||
)
|
||||
raise ActiveRecord::Rollback if doc && doc.id.nil?
|
||||
self.legal_documents = [doc]
|
||||
|
||||
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
|
||||
self.legal_document_id = doc.id
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue