From d31f1b8869853d90cd18f52b56311efa1382157a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Mon, 30 Sep 2024 16:04:38 +0200 Subject: [PATCH 1/2] fix: indicate some attributes have only mandatory / not_important options --- lib/ProductOpener/Attributes.pm | 5 +++++ lib/ProductOpener/Config_off.pm | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/ProductOpener/Attributes.pm b/lib/ProductOpener/Attributes.pm index 0fb4b8fba081c..bd43e2397e455 100644 --- a/lib/ProductOpener/Attributes.pm +++ b/lib/ProductOpener/Attributes.pm @@ -166,6 +166,11 @@ sub list_attributes ($target_lc) { foreach my $attribute_id (@{$attributes_ref}) { my $attribute_ref = initialize_attribute($attribute_id, $target_lc); + + # Add the possible values for the attribute + $attribute_ref->{values} + = deep_get(\%options, "attribute_values", $attribute_id) || $options{attribute_values_default}; + push @{$group_ref->{attributes}}, $attribute_ref; } diff --git a/lib/ProductOpener/Config_off.pm b/lib/ProductOpener/Config_off.pm index b6ee9c7f01037..11519435c58e9 100644 --- a/lib/ProductOpener/Config_off.pm +++ b/lib/ProductOpener/Config_off.pm @@ -983,6 +983,29 @@ $options{attribute_groups} = [ ["environment", ["ecoscore", "forest_footprint",]], ]; +# By default attributes have 4 possible values: mandatory, very_important, important, not_important +# For some attributes, like allergens or vegan, we can limit to 2 values: mandatory, not_important +$options{attribute_values_default} = ["mandatory", "very_important", "important", "not_important"]; + +$options{attribute_values} = { + "allergens_no_gluten" => ["mandatory", "not_important"], + "allergens_no_milk" => ["mandatory", "not_important"], + "allergens_no_eggs" => ["mandatory", "not_important"], + "allergens_no_nuts" => ["mandatory", "not_important"], + "allergens_no_peanuts" => ["mandatory", "not_important"], + "allergens_no_sesame_seeds" => ["mandatory", "not_important"], + "allergens_no_soybeans" => ["mandatory", "not_important"], + "allergens_no_celery" => ["mandatory", "not_important"], + "allergens_no_mustard" => ["mandatory", "not_important"], + "allergens_no_lupin" => ["mandatory", "not_important"], + "allergens_no_fish" => ["mandatory", "not_important"], + "allergens_no_crustaceans" => ["mandatory", "not_important"], + "allergens_no_molluscs" => ["mandatory", "not_important"], + "allergens_no_sulphur_dioxide_and_sulphites" => ["mandatory", "not_important"], + "vegan" => ["mandatory", "not_important"], + "vegetarian" => ["mandatory", "not_important"], +}; + # default preferences for attributes $options{attribute_default_preferences} = { "nutriscore" => "very_important", From 89274e789e10f0646f08d13d0aab30330a6cf97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Mon, 30 Sep 2024 16:10:42 +0200 Subject: [PATCH 2/2] fix: indicate some attributes have only mandatory / not_important options --- lib/ProductOpener/Config_off.pm | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/ProductOpener/Config_off.pm b/lib/ProductOpener/Config_off.pm index 11519435c58e9..2e0fc1dc5e946 100644 --- a/lib/ProductOpener/Config_off.pm +++ b/lib/ProductOpener/Config_off.pm @@ -983,27 +983,27 @@ $options{attribute_groups} = [ ["environment", ["ecoscore", "forest_footprint",]], ]; -# By default attributes have 4 possible values: mandatory, very_important, important, not_important -# For some attributes, like allergens or vegan, we can limit to 2 values: mandatory, not_important -$options{attribute_values_default} = ["mandatory", "very_important", "important", "not_important"]; +# By default attributes have 4 possible values: not_important, important, very_important, mandatory +# For some attributes, like allergens or vegan, we can limit to 2 values: not_important, mandatory +$options{attribute_values_default} = ["not_important", "important", "very_important", "mandatory"]; $options{attribute_values} = { - "allergens_no_gluten" => ["mandatory", "not_important"], - "allergens_no_milk" => ["mandatory", "not_important"], - "allergens_no_eggs" => ["mandatory", "not_important"], - "allergens_no_nuts" => ["mandatory", "not_important"], - "allergens_no_peanuts" => ["mandatory", "not_important"], - "allergens_no_sesame_seeds" => ["mandatory", "not_important"], - "allergens_no_soybeans" => ["mandatory", "not_important"], - "allergens_no_celery" => ["mandatory", "not_important"], - "allergens_no_mustard" => ["mandatory", "not_important"], - "allergens_no_lupin" => ["mandatory", "not_important"], - "allergens_no_fish" => ["mandatory", "not_important"], - "allergens_no_crustaceans" => ["mandatory", "not_important"], - "allergens_no_molluscs" => ["mandatory", "not_important"], - "allergens_no_sulphur_dioxide_and_sulphites" => ["mandatory", "not_important"], - "vegan" => ["mandatory", "not_important"], - "vegetarian" => ["mandatory", "not_important"], + "allergens_no_gluten" => ["not_important", "mandatory"], + "allergens_no_milk" => ["not_important", "mandatory"], + "allergens_no_eggs" => ["not_important", "mandatory"], + "allergens_no_nuts" => ["not_important", "mandatory"], + "allergens_no_peanuts" => ["not_important", "mandatory"], + "allergens_no_sesame_seeds" => ["not_important", "mandatory"], + "allergens_no_soybeans" => ["not_important", "mandatory"], + "allergens_no_celery" => ["not_important", "mandatory"], + "allergens_no_mustard" => ["not_important", "mandatory"], + "allergens_no_lupin" => ["not_important", "mandatory"], + "allergens_no_fish" => ["not_important", "mandatory"], + "allergens_no_crustaceans" => ["not_important", "mandatory"], + "allergens_no_molluscs" => ["not_important", "mandatory"], + "allergens_no_sulphur_dioxide_and_sulphites" => ["not_important", "mandatory"], + "vegan" => ["not_important", "mandatory"], + "vegetarian" => ["not_important", "mandatory"], }; # default preferences for attributes