From b5c1200bf16921b4b7998affec9642a28e27d9e8 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 26 May 2021 17:28:57 +0200 Subject: [PATCH] disallow download archive button if to heavy Co-authored-by: Christophe Robillard --- app/views/instructeurs/archives/index.html.haml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/instructeurs/archives/index.html.haml b/app/views/instructeurs/archives/index.html.haml index c8060ad4f..5db5f06e7 100644 --- a/app/views/instructeurs/archives/index.html.haml +++ b/app/views/instructeurs/archives/index.html.haml @@ -60,16 +60,17 @@ - month = count_by_month["month"].to_date - nb_dossiers_termines = count_by_month["count"] - matching_archive = @archives.find { |archive| archive.time_span_type == 'monthly' && archive.month == month } + - if matching_archive.present? && matching_archive.available? + - weight = matching_archive.file.byte_size + - else + - weight = nb_dossiers_termines * @average_dossier_weight + %tr %td = I18n.l(month, format: "%B %Y") %td = nb_dossiers_termines %td - - if matching_archive.present? && matching_archive.available? - - weight = matching_archive.file.byte_size - - else - - weight = nb_dossiers_termines * @average_dossier_weight = number_to_human_size(weight) %td - if matching_archive.present? @@ -80,8 +81,10 @@ - else %span.icon.retry = t(:archive_pending_html, created_period: time_ago_in_words(matching_archive.created_at), scope: [:instructeurs, :procedure]) - - else + - elsif weight < 1.gigabyte = link_to instructeur_archives_path(@procedure, type:'monthly', month: month.strftime('%Y-%m')), method: :post, class: "button" do %span.icon.new-folder Démander la création + - else + Archive trop volumineuse