prend en compte uniquement les pj pour estimer la taille d'un dossier
This commit is contained in:
parent
71a48c99bb
commit
01f180022b
7 changed files with 60 additions and 37 deletions
|
@ -211,7 +211,7 @@ module Instructeurs
|
|||
end
|
||||
|
||||
def telecharger_pjs
|
||||
return head(:forbidden) if !dossier.attachments_downloadable?
|
||||
return head(:forbidden) if !dossier.export_and_attachments_downloadable?
|
||||
|
||||
files = ActiveStorage::DownloadableFile.create_list_from_dossier(dossier)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class ActiveStorage::DownloadableFile
|
||||
def self.create_list_from_dossier(dossier)
|
||||
dossier_export = PiecesJustificativesService.generate_dossier_export(dossier)
|
||||
pjs = [dossier_export] + PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
||||
pjs = [dossier_export] + PiecesJustificativesService.liste_documents(dossier)
|
||||
pjs.map do |piece_justificative|
|
||||
[
|
||||
piece_justificative,
|
||||
|
|
|
@ -873,9 +873,8 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def attachments_downloadable?
|
||||
PiecesJustificativesService.liste_pieces_justificatives(self).present? \
|
||||
&& PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP
|
||||
def export_and_attachments_downloadable?
|
||||
PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP
|
||||
end
|
||||
|
||||
def linked_dossiers_for(instructeur_or_expert)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class PiecesJustificativesService
|
||||
def self.liste_pieces_justificatives(dossier)
|
||||
def self.liste_documents(dossier)
|
||||
pjs_champs = pjs_for_champs(dossier)
|
||||
pjs_commentaires = pjs_for_commentaires(dossier)
|
||||
pjs_dossier = pjs_for_dossier(dossier)
|
||||
|
@ -8,6 +8,14 @@ class PiecesJustificativesService
|
|||
.filter(&:attached?)
|
||||
end
|
||||
|
||||
def self.liste_pieces_justificatives(dossier)
|
||||
pjs_champs = pjs_for_champs(dossier)
|
||||
pjs_commentaires = pjs_for_commentaires(dossier)
|
||||
|
||||
(pjs_champs + pjs_commentaires)
|
||||
.filter(&:attached?)
|
||||
end
|
||||
|
||||
def self.pieces_justificatives_total_size(dossier)
|
||||
liste_pieces_justificatives(dossier)
|
||||
.sum(&:byte_size)
|
||||
|
|
|
@ -12,16 +12,15 @@
|
|||
%li
|
||||
= link_to "Export GeoJSON", geo_data_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
|
||||
|
||||
- if PiecesJustificativesService.liste_pieces_justificatives(dossier).present?
|
||||
%span.dropdown.print-menu-opener
|
||||
%button.button.dropdown-button.icon-only{ 'aria-expanded' => 'false', 'aria-controls' => 'print-pj-menu' }
|
||||
%span.icon.attached
|
||||
%ul#print-pj-menu.print-menu.dropdown-content
|
||||
%li
|
||||
- if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP
|
||||
= link_to "Télécharger le dossier et toutes ses pièces jointes", telecharger_pjs_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
|
||||
- else
|
||||
%p.menu-item Le téléchargement des pièces jointes est désactivé pour les dossiers de plus de #{number_to_human_size Dossier::TAILLE_MAX_ZIP}.
|
||||
%span.dropdown.print-menu-opener
|
||||
%button.button.dropdown-button.icon-only{ 'aria-expanded' => 'false', 'aria-controls' => 'print-pj-menu' }
|
||||
%span.icon.attached
|
||||
%ul#print-pj-menu.print-menu.dropdown-content
|
||||
%li
|
||||
- if dossier.export_and_attachments_downloadable?
|
||||
= link_to "Télécharger le dossier et toutes ses pièces jointes", telecharger_pjs_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
|
||||
- else
|
||||
%p.menu-item Le téléchargement des pièces jointes est désactivé pour les dossiers de plus de #{number_to_human_size Dossier::TAILLE_MAX_ZIP}.
|
||||
|
||||
= render partial: "instructeurs/procedures/dossier_actions",
|
||||
locals: { procedure_id: dossier.procedure.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue