store attestation sociale and display
This commit is contained in:
parent
d74b14c205
commit
158b4802ab
9 changed files with 44 additions and 4 deletions
|
@ -4,6 +4,8 @@ class Etablissement < ApplicationRecord
|
|||
has_one :champ, class_name: 'Champs::SiretChamp'
|
||||
has_many :exercices, dependent: :destroy
|
||||
|
||||
has_one_attached :entreprise_attestation_sociale
|
||||
|
||||
accepts_nested_attributes_for :exercices
|
||||
|
||||
validates :siret, presence: true
|
||||
|
@ -114,6 +116,19 @@ class Etablissement < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
def upload_attestation_sociale(url)
|
||||
filename = File.basename(URI.parse(url).path)
|
||||
response = Typhoeus.get(url)
|
||||
|
||||
if response.success?
|
||||
entreprise_attestation_sociale.attach(
|
||||
io: StringIO.new(response.body),
|
||||
filename: filename,
|
||||
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dossier_id_for_export
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue