extract pj_path method
This commit is contained in:
parent
97443e2ff6
commit
d5241381eb
1 changed files with 8 additions and 6 deletions
|
@ -3,17 +3,19 @@ class ActiveStorage::DownloadableFile
|
|||
dossiers.flat_map do |dossier|
|
||||
dossier_export = PiecesJustificativesService.generate_dossier_export(dossier)
|
||||
pjs = [dossier_export] + PiecesJustificativesService.liste_documents(dossier, for_expert)
|
||||
pjs.map do |piece_justificative|
|
||||
[
|
||||
piece_justificative,
|
||||
"dossier-#{dossier.id}/#{self.timestamped_filename(piece_justificative)}"
|
||||
]
|
||||
end
|
||||
pjs.map { |piece_justificative| pj_and_path(dossier, piece_justificative) }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.pj_and_path(dossier, pj)
|
||||
[
|
||||
pj,
|
||||
"dossier-#{dossier.id}/#{self.timestamped_filename(pj)}"
|
||||
]
|
||||
end
|
||||
|
||||
def self.timestamped_filename(attachment)
|
||||
# we pad the original file name with a timestamp
|
||||
# and a short id in order to help identify multiple versions and avoid name collisions
|
||||
|
|
Loading…
Reference in a new issue