diff --git a/app/controllers/experts/avis_controller.rb b/app/controllers/experts/avis_controller.rb index a943523ad..6523fcd2c 100644 --- a/app/controllers/experts/avis_controller.rb +++ b/app/controllers/experts/avis_controller.rb @@ -139,8 +139,6 @@ module Experts end def telecharger_pjs - return head(:forbidden) if !avis.dossier.export_and_attachments_downloadable? - files = ActiveStorage::DownloadableFile.create_list_from_dossier(@dossier, true) zipline(files, "dossier-#{@dossier.id}.zip") diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index 740305d04..8612359ea 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -218,8 +218,6 @@ module Instructeurs end def telecharger_pjs - return head(:forbidden) if !dossier.export_and_attachments_downloadable? - files = ActiveStorage::DownloadableFile.create_list_from_dossier(dossier) zipline(files, "dossier-#{dossier.id}.zip") diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 700e6070a..d27e058c7 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -56,8 +56,6 @@ class Dossier < ApplicationRecord INSTRUCTION_COMMENCEE = TERMINE + [states.fetch(:en_instruction)] SOUMIS = EN_CONSTRUCTION_OU_INSTRUCTION + TERMINE - TAILLE_MAX_ZIP = 100.megabytes - REMAINING_DAYS_BEFORE_CLOSING = 2 INTERVAL_BEFORE_CLOSING = "#{REMAINING_DAYS_BEFORE_CLOSING} days" REMAINING_WEEKS_BEFORE_EXPIRATION = 2 @@ -1084,10 +1082,6 @@ class Dossier < ApplicationRecord end end - def export_and_attachments_downloadable? - PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP - end - def linked_dossiers_for(instructeur_or_expert) dossier_ids = champs.filter(&:dossier_link?).filter_map(&:value) instructeur_or_expert.dossiers.where(id: dossier_ids) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 729250b5d..ca5554518 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -14,11 +14,6 @@ class PiecesJustificativesService pjs_champs + pjs_commentaires end - def self.pieces_justificatives_total_size(dossier) - liste_pieces_justificatives(dossier) - .sum(&:byte_size) - end - def self.serialize_types_de_champ_as_type_pj(revision) tdcs = revision.types_de_champ.filter { |type_champ| type_champ.old_pj.present? } tdcs.map.with_index do |type_champ, order_place| diff --git a/app/views/experts/avis/_header.html.haml b/app/views/experts/avis/_header.html.haml index 74f3749d4..487bd878e 100644 --- a/app/views/experts/avis/_header.html.haml +++ b/app/views/experts/avis/_header.html.haml @@ -9,11 +9,7 @@ %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_expert_avis_path(avis), 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}. + %li= link_to "Télécharger le dossier et toutes ses pièces jointes", telecharger_pjs_expert_avis_path(avis), target: "_blank", rel: "noopener", class: "menu-item menu-link" %nav.tabs %ul diff --git a/app/views/instructeurs/dossiers/_header_actions.html.haml b/app/views/instructeurs/dossiers/_header_actions.html.haml index 671340d53..c64f4d9ab 100644 --- a/app/views/instructeurs/dossiers/_header_actions.html.haml +++ b/app/views/instructeurs/dossiers/_header_actions.html.haml @@ -16,11 +16,7 @@ %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}. + %li= 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" = render partial: "instructeurs/procedures/dossier_actions", locals: { procedure_id: dossier.procedure.id, diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 3c3dbc4ab..4dcc91063 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -1190,30 +1190,6 @@ describe Dossier do after { Timecop.return } end - describe '#export_and_attachments_downloadable?' do - let(:dossier) { create(:dossier, user: user) } - - context "no attachments" do - it { - expect(dossier.export_and_attachments_downloadable?).to be true - } - end - - context "with a small attachment" do - it { - expect(PiecesJustificativesService).to receive(:pieces_justificatives_total_size).and_return(4.megabytes) - expect(dossier.export_and_attachments_downloadable?).to be true - } - end - - context "with a too large attachment" do - it { - expect(PiecesJustificativesService).to receive(:pieces_justificatives_total_size).and_return(100.megabytes) - expect(dossier.export_and_attachments_downloadable?).to be false - } - end - end - describe '#notify_draft_not_submitted' do let!(:user1) { create(:user) } let!(:user2) { create(:user) }