store attestation fiscale and display
This commit is contained in:
parent
38c68b16e3
commit
3ddb5a4cb4
6 changed files with 45 additions and 6 deletions
|
@ -5,6 +5,7 @@ class Etablissement < ApplicationRecord
|
|||
has_many :exercices, dependent: :destroy
|
||||
|
||||
has_one_attached :entreprise_attestation_sociale
|
||||
has_one_attached :entreprise_attestation_fiscale
|
||||
|
||||
accepts_nested_attributes_for :exercices
|
||||
|
||||
|
@ -116,12 +117,12 @@ class Etablissement < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
def upload_attestation_sociale(url)
|
||||
def upload_attestation(url, attestation)
|
||||
filename = File.basename(URI.parse(url).path)
|
||||
response = Typhoeus.get(url)
|
||||
|
||||
if response.success?
|
||||
entreprise_attestation_sociale.attach(
|
||||
attestation.attach(
|
||||
io: StringIO.new(response.body),
|
||||
filename: filename,
|
||||
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
|
||||
|
@ -129,6 +130,14 @@ class Etablissement < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def upload_attestation_sociale(url)
|
||||
upload_attestation(url, entreprise_attestation_sociale)
|
||||
end
|
||||
|
||||
def upload_attestation_fiscale(url)
|
||||
upload_attestation(url, entreprise_attestation_fiscale)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dossier_id_for_export
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue