disallow download archive button if to heavy

Co-authored-by: Christophe Robillard <christophe.robillard@beta.gouv.fr>
This commit is contained in:
simon lehericey 2021-05-26 17:28:57 +02:00 committed by Christophe Robillard
parent 61b5085390
commit b5c1200bf1

View file

@ -60,16 +60,17 @@
- month = count_by_month["month"].to_date - month = count_by_month["month"].to_date
- nb_dossiers_termines = count_by_month["count"] - nb_dossiers_termines = count_by_month["count"]
- matching_archive = @archives.find { |archive| archive.time_span_type == 'monthly' && archive.month == month } - 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 %tr
%td %td
= I18n.l(month, format: "%B %Y") = I18n.l(month, format: "%B %Y")
%td %td
= nb_dossiers_termines = nb_dossiers_termines
%td %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) = number_to_human_size(weight)
%td %td
- if matching_archive.present? - if matching_archive.present?
@ -80,8 +81,10 @@
- else - else
%span.icon.retry %span.icon.retry
= t(:archive_pending_html, created_period: time_ago_in_words(matching_archive.created_at), scope: [:instructeurs, :procedure]) = 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 = link_to instructeur_archives_path(@procedure, type:'monthly', month: month.strftime('%Y-%m')), method: :post, class: "button" do
%span.icon.new-folder %span.icon.new-folder
Démander la création Démander la création
- else
Archive trop volumineuse