feat(gallery): add attachments from avis

This commit is contained in:
Eric Leroy-Terquem 2024-10-09 17:41:46 +02:00
parent e95e86faae
commit d10df6e17c
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
5 changed files with 99 additions and 8 deletions

View file

@ -513,11 +513,16 @@ module Instructeurs
.commentaires
.includes(piece_jointe_attachments: :blob)
.map(&:piece_jointe)
.map(&:attachments)
.flatten
.flat_map(&:attachments)
.map(&:id)
champs_attachments_ids + commentaires_attachments_ids
avis_attachments_ids = dossier
.avis.flat_map { [_1.introduction_file, _1.piece_justificative_file] }
.flat_map(&:attachments)
.compact
.map(&:id)
champs_attachments_ids + commentaires_attachments_ids + avis_attachments_ids
end
@gallery_attachments = ActiveStorage::Attachment.where(id: gallery_attachments_ids)
end