From 5dd0667dd086ab8cb4dff0e5967cd8c77f41c811 Mon Sep 17 00:00:00 2001 From: himanshisrestha <135853264+himanshisrestha@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:17:30 +0530 Subject: [PATCH] fix: issue #9876 import spreadsheet template with mandatory fields (#9934) --- .env | 2 +- cgi/generate_sample_import_file.pl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 6a7d32ccbf0ad..ea7465c8a51fa 100644 --- a/.env +++ b/.env @@ -64,4 +64,4 @@ ELASTICSEARCH_HOSTS= LOG_LEVEL_ROOT=TRACE LOG_LEVEL_MONGODB=TRACE -BUILD_CACHE_REPO=openfoodfacts/openfoodfacts-build-cache +BUILD_CACHE_REPO=openfoodfacts/openfoodfacts-build-cache \ No newline at end of file diff --git a/cgi/generate_sample_import_file.pl b/cgi/generate_sample_import_file.pl index de2c2a8f533b2..7a210dd000ac1 100755 --- a/cgi/generate_sample_import_file.pl +++ b/cgi/generate_sample_import_file.pl @@ -99,6 +99,8 @@ $worksheet->set_column('A:A', 30); $worksheet->write($description_row, 0, $description, $formats{'description'}); +my $fields_param = param('fields'); + foreach my $group_ref (@$select2_options_ref) { my $group_start_col = $col; @@ -209,6 +211,9 @@ } # Write cell and comment + if ($fields_param && $fields_param eq 'mandatory' && $importance ne 'mandatory') { + next; + } $worksheet->write($headers_row, $col, $field_ref->{text}, $formats{$importance}); my $width = length($field_ref->{text}); @@ -227,4 +232,3 @@ } exit(0); -