add pdf to pjs export
This commit is contained in:
parent
e90957dd32
commit
60cc4d3697
6 changed files with 32 additions and 10 deletions
|
@ -210,6 +210,7 @@ module Instructeurs
|
|||
def telecharger_pjs
|
||||
return head(:forbidden) if !dossier.attachments_downloadable?
|
||||
|
||||
generate_pdf_for_instructeur_export
|
||||
files = ActiveStorage::DownloadableFile.create_list_from_dossier(dossier)
|
||||
|
||||
zipline(files, "dossier-#{dossier.id}.zip")
|
||||
|
@ -232,6 +233,12 @@ module Instructeurs
|
|||
@dossier ||= current_instructeur.dossiers.find(params[:dossier_id])
|
||||
end
|
||||
|
||||
def generate_pdf_for_instructeur_export
|
||||
@include_infos_administration = true
|
||||
pdf = render_to_string(file: 'dossiers/show', formats: [:pdf])
|
||||
dossier.pdf_export_for_instructeur.attach(io: StringIO.open(pdf), filename: "export-#{dossier.id}.pdf", content_type: 'application/pdf')
|
||||
end
|
||||
|
||||
def commentaire_params
|
||||
params.require(:commentaire).permit(:body, :piece_jointe)
|
||||
end
|
||||
|
|
|
@ -13,12 +13,14 @@ class ActiveStorage::DownloadableFile
|
|||
|
||||
def self.create_list_from_dossier(dossier)
|
||||
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
||||
pjs.map do |piece_justificative|
|
||||
files = pjs.map do |piece_justificative|
|
||||
[
|
||||
piece_justificative,
|
||||
self.timestamped_filename(piece_justificative)
|
||||
]
|
||||
end
|
||||
files << [dossier.pdf_export_for_instructeur, self.timestamped_filename(dossier.pdf_export_for_instructeur)]
|
||||
files
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -63,6 +63,7 @@ class Dossier < ApplicationRecord
|
|||
has_one :france_connect_information, through: :user
|
||||
|
||||
has_one_attached :justificatif_motivation
|
||||
has_one_attached :pdf_export_for_instructeur
|
||||
|
||||
has_many :champs, -> { root.public_ordered }, inverse_of: :dossier, dependent: :destroy
|
||||
has_many :champs_private, -> { root.private_ordered }, class_name: 'Champ', inverse_of: :dossier, dependent: :destroy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue