-
-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: report a problem panels (OFF data + French SignalConso) (#10106)
- Loading branch information
1 parent
bdc0168
commit 4d19492
Showing
33 changed files
with
1,775 additions
and
54 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# This file is part of Product Opener. | ||
# | ||
# Product Opener | ||
# Copyright (C) 2011-2023 Association Open Food Facts | ||
# Contact: [email protected] | ||
# Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France | ||
# | ||
# Product Opener is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
=head1 NAME | ||
ProductOpener::KnowledgePanelsReportProblem - Generate knowledge panels to report a problem with the data or the product | ||
=head1 SYNOPSIS | ||
Knowledge panels to indicate how to report a problem with the product data, | ||
or with the product (e.g. link to report to authorities like SignalConso in France) | ||
=cut | ||
|
||
package ProductOpener::KnowledgePanelsReportProblem; | ||
|
||
use ProductOpener::PerlStandards; | ||
use Exporter qw< import >; | ||
|
||
use Log::Any qw($log); | ||
|
||
BEGIN { | ||
use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); | ||
@EXPORT_OK = qw( | ||
&create_report_problem_card_panel | ||
&create_data_quality_panel | ||
); # symbols to export on request | ||
%EXPORT_TAGS = (all => [@EXPORT_OK]); | ||
} | ||
|
||
use vars @EXPORT_OK; | ||
|
||
use ProductOpener::KnowledgePanels qw(create_panel_from_json_template); | ||
use ProductOpener::Tags qw(:all); | ||
|
||
use Encode; | ||
use Data::DeepAccess qw(deep_get); | ||
|
||
=head2 create_report_problem_card_panel ( $product_ref, $target_lc, $target_cc, $options_ref ) | ||
Creates a knowledge panel card that contains all knowledge panels related to reporting problems. | ||
=head3 Arguments | ||
=head4 product reference $product_ref | ||
Loaded from the MongoDB database, Storable files, or the OFF API. | ||
=head4 language code $target_lc | ||
Returned attributes contain both data and strings intended to be displayed to users. | ||
This parameter sets the desired language for the user facing strings. | ||
=head4 country code $target_cc | ||
We may display country specific recommendations from health authorities, or country specific scores. | ||
=head4 options reference $options_ref | ||
=cut | ||
|
||
sub create_report_problem_card_panel ($product_ref, $target_lc, $target_cc, $options_ref) { | ||
|
||
$log->debug("create contribution card panel", {code => $product_ref->{code}}) if $log->is_debug(); | ||
|
||
my @panels = (); | ||
my $panel_data_ref = {}; | ||
|
||
# TODO: add a panel to display the consumer service contact information if we have it | ||
# for the owner of the product. Otherwise, warn that we don't make or sell the product | ||
# + add promo message for the pro platform ("Are you the owner? Add your contact information") | ||
|
||
# Panel to tell users that they can fix the data themselves | ||
|
||
create_panel_from_json_template( | ||
"incomplete_or_incorrect_data", | ||
"api/knowledge-panels/report_problem/incomplete_or_incorrect_data.tt.json", | ||
$panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref | ||
); | ||
push(@panels, "incomplete_or_incorrect_data"); | ||
|
||
# TODO: add a panel for Nutri-Patrol once it is ready | ||
|
||
# Panels to report product issues to local authorities | ||
|
||
# France - SignalConso | ||
|
||
if (($target_cc eq "fr") and ($target_lc eq "fr")) { | ||
|
||
create_panel_from_json_template( | ||
"fr_report_product_signalconso", | ||
"api/knowledge-panels/report_problem/fr_report_product_signalconso.tt.json", | ||
$panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref | ||
); | ||
push(@panels, "fr_report_product_signalconso"); | ||
} | ||
|
||
my $panel_data_ref = {report_problem_panels => \@panels,}; | ||
create_panel_from_json_template("report_problem_card", | ||
"api/knowledge-panels/report_problem/report_problem_card.tt.json", | ||
$panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref); | ||
|
||
return; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,7 @@ scrypt | |
Scrypt | ||
serverTimePretty | ||
sftp | ||
SignalConso | ||
sirop | ||
slad | ||
Sonnenblumen | ||
|
35 changes: 35 additions & 0 deletions
35
templates/api/knowledge-panels/report_problem/fr_report_product_signalconso.tt.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"level": "info", | ||
"topics": [ | ||
"problem" | ||
], | ||
"expand_for": "large", | ||
"evaluation": "neutral", | ||
"title_element": { | ||
"title": "Faire un signalement sur SignalConso", | ||
"subtitle": "Etiquetage non conforme, vente d'un produit périmé, présence d'un corps étranger, etc.", | ||
"icon_url": "[% static_subdomain %]/images/panels/report_problem/signalconso.png", | ||
}, | ||
"elements": [ | ||
{ | ||
"element_type": "text", | ||
"text_element": { | ||
"html": ` | ||
Vous avez rencontré un problème avec ce produit : <b>étiquetage non conforme, produit périmé encore en vente, | ||
présence d'un corps étranger, etc.</b> ?<br> | ||
Faites un signalement à l'entreprise et à la répression des fraudes sur SignalConso, un outil de la | ||
Direction générale de la concurrence, de la consommation et de la répression des fraudes (DGCCRF). | ||
` | ||
}, | ||
}, | ||
{ | ||
"element_type": "image", | ||
"image_element": { | ||
"url": "[% static_subdomain %]/images/panels/report_problem/signalconso-button.png", | ||
"alt": "Je fais un signalement sur SignalConso", | ||
"link_url": "https://signal.conso.gouv.fr/fr/alimentaire-codebarres/faire-un-signalement?gtin=[% product.code %]&utm_source=openfoodfacts&utm_campaign=product_page_panel" | ||
} | ||
|
||
} | ||
] | ||
} |
Oops, something went wrong.