This commit is contained in:
simon lehericey 2022-04-07 15:23:18 +02:00 committed by Paul Chavard
parent 5337fa02e3
commit 9c73bf1932
4 changed files with 27 additions and 19 deletions

View file

@ -1,8 +1,7 @@
class ActiveStorage::DownloadableFile
def self.create_list_from_dossiers(dossiers, for_expert = false)
dossiers
.map { |d| pj_and_path(d.id, PiecesJustificativesService.generate_dossier_export(d)) } +
PiecesJustificativesService.liste_documents(dossiers, for_expert)
PiecesJustificativesService.generate_dossier_export(dossiers) +
PiecesJustificativesService.liste_documents(dossiers, for_expert)
end
private

View file

@ -107,21 +107,29 @@ class PiecesJustificativesService
end
end
def self.generate_dossier_export(dossier)
pdf = ApplicationController
.render(template: 'dossiers/show', formats: [:pdf],
assigns: {
include_infos_administration: true,
dossier: dossier
})
def self.generate_dossier_export(dossiers)
pdfs = []
FakeAttachment.new(
file: StringIO.new(pdf),
filename: "export-#{dossier.id}.pdf",
name: 'pdf_export_for_instructeur',
id: dossier.id,
created_at: dossier.updated_at
)
dossiers.find_each do |dossier|
pdf = ApplicationController
.render(template: 'dossiers/show', formats: [:pdf],
assigns: {
include_infos_administration: true,
dossier: dossier
})
a = FakeAttachment.new(
file: StringIO.new(pdf),
filename: "export-#{dossier.id}.pdf",
name: 'pdf_export_for_instructeur',
id: dossier.id,
created_at: dossier.updated_at
)
pdfs << ActiveStorage::DownloadableFile.pj_and_path(dossier.id, a)
end
pdfs
end
private