4378 Ajout des PJ de la messagerie dans le zip des PJs du dossier
This commit is contained in:
parent
9a3be41c90
commit
9503a363e5
2 changed files with 10 additions and 5 deletions
|
@ -13,10 +13,10 @@ class ActiveStorage::DownloadableFile
|
||||||
|
|
||||||
def self.create_list_from_dossier(dossier)
|
def self.create_list_from_dossier(dossier)
|
||||||
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
||||||
pjs.map do |pj|
|
pjs.map do |piece_justificative|
|
||||||
[
|
[
|
||||||
ActiveStorage::DownloadableFile.new(pj.piece_justificative_file),
|
ActiveStorage::DownloadableFile.new(piece_justificative),
|
||||||
pj.piece_justificative_file.filename.to_s
|
piece_justificative.filename.to_s
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
class PiecesJustificativesService
|
class PiecesJustificativesService
|
||||||
def self.liste_pieces_justificatives(dossier)
|
def self.liste_pieces_justificatives(dossier)
|
||||||
|
pjs_commentaires = dossier.commentaires
|
||||||
|
.map(&:piece_jointe)
|
||||||
|
.filter(&:attached?)
|
||||||
|
|
||||||
champs_blocs_repetables = dossier.champs
|
champs_blocs_repetables = dossier.champs
|
||||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
|
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
|
||||||
.flat_map(&:champs)
|
.flat_map(&:champs)
|
||||||
|
|
||||||
champs_pieces_justificatives_with_attachments(
|
pjs_commentaires + champs_pieces_justificatives_with_attachments(
|
||||||
champs_blocs_repetables + dossier.champs
|
champs_blocs_repetables + dossier.champs
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.pieces_justificatives_total_size(dossier)
|
def self.pieces_justificatives_total_size(dossier)
|
||||||
liste_pieces_justificatives(dossier)
|
liste_pieces_justificatives(dossier)
|
||||||
.sum { |pj| pj.piece_justificative_file.byte_size }
|
.sum(&:byte_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.serialize_types_de_champ_as_type_pj(procedure)
|
def self.serialize_types_de_champ_as_type_pj(procedure)
|
||||||
|
@ -48,5 +52,6 @@ class PiecesJustificativesService
|
||||||
champs
|
champs
|
||||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) }
|
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) }
|
||||||
.filter { |pj| pj.piece_justificative_file.attached? }
|
.filter { |pj| pj.piece_justificative_file.attached? }
|
||||||
|
.map(&:piece_justificative_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue