Skip to content

Commit

Permalink
change max lines to csv referentiel
Browse files Browse the repository at this point in the history
  • Loading branch information
lisa-durand committed Feb 18, 2025
1 parent 8fb59d7 commit fd13d1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
%span.fr-download__detail
= template_detail
.fr-hint-text.fr-mb-1w
Votre fichier doit peser maximum #{number_to_human_size(referentiel_max_size)} et ne doit pas contenir plus de #{referentiel_max_lines} lignes.
Votre fichier doit peser maximum #{number_to_human_size(referentiel_max_size)} et ne doit pas contenir plus de #{number_with_delimiter(referentiel_max_lines)} lignes.
.flex.column
= file_field_tag :referentiel_file, required: true, accept: 'text/csv', size: "1", class: 'fr-mb-2w', id: dom_id(type_de_champ, :import_referentiel)

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/administrateurs/types_de_champ_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TypesDeChampController < AdministrateurController
before_action :reload_procedure_with_includes, only: [:destroy]

CSV_MAX_SIZE = 1.megabyte
CSV_MAX_LINES = 1000
CSV_MAX_LINES = 5_000
CSV_ACCEPTED_CONTENT_TYPES = [
"text/csv",
"application/vnd.ms-excel"
Expand Down Expand Up @@ -155,7 +155,7 @@ def import_referentiel

csv_to_code = ACSV::CSV.new_for_ruby3(file.encode("UTF-8", base_encoding[:encoding], invalid: :replace, replace: ""), headers: true).map(&:to_h)

return flash[:alert] = "Importation impossible : votre fichier CSV fait plus de 1000 lignes" if csv_to_code.size > 1000
return flash[:alert] = "Importation impossible : votre fichier CSV fait plus de #{helpers.number_with_delimiter(CSV_MAX_LINES)} lignes" if csv_to_code.size > CSV_MAX_LINES

headers = csv_to_code.first.keys

Expand Down

0 comments on commit fd13d1b

Please sign in to comment.