mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Don't create new legaldoc if it's already persistent
This commit is contained in:
parent
eb09447ee1
commit
58443f23aa
2 changed files with 4 additions and 14 deletions
|
@ -184,12 +184,10 @@ class Epp::Domain < Domain
|
||||||
def add_legal_file_to_new frame
|
def add_legal_file_to_new frame
|
||||||
legal_document_data = ::Deserializers::Xml::LegalDocument.new(frame).call
|
legal_document_data = ::Deserializers::Xml::LegalDocument.new(frame).call
|
||||||
return unless legal_document_data
|
return unless legal_document_data
|
||||||
|
return if legal_document_data[:body].starts_with?(ENV['legal_documents_dir'])
|
||||||
|
|
||||||
doc = LegalDocument.create(
|
doc = LegalDocument.create(documentable_type: Domain, document_type: legal_document_data[:type],
|
||||||
documentable_type: Domain,
|
body: legal_document_data[:body])
|
||||||
document_type: legal_document_data[:type],
|
|
||||||
body: legal_document_data[:body]
|
|
||||||
)
|
|
||||||
self.legal_documents = [doc]
|
self.legal_documents = [doc]
|
||||||
|
|
||||||
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
|
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
|
||||||
|
@ -543,6 +541,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
def attach_legal_document(legal_document_data)
|
def attach_legal_document(legal_document_data)
|
||||||
return unless legal_document_data
|
return unless legal_document_data
|
||||||
|
return if legal_document_data[:body].starts_with?(ENV['legal_documents_dir'])
|
||||||
|
|
||||||
legal_documents.create(
|
legal_documents.create(
|
||||||
document_type: legal_document_data[:type],
|
document_type: legal_document_data[:type],
|
||||||
|
|
|
@ -28,18 +28,9 @@ class LegalDocument < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def val_body_length
|
def val_body_length
|
||||||
if body.start_with? ENV['legal_documents_dir']
|
|
||||||
if File.exist? body
|
|
||||||
self.path = body
|
|
||||||
self.body = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE
|
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def save_to_filesystem
|
def save_to_filesystem
|
||||||
binary = Base64.decode64(body)
|
binary = Base64.decode64(body)
|
||||||
digest = Digest::SHA1.new.update(binary).to_s
|
digest = Digest::SHA1.new.update(binary).to_s
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue