Skip to content

Commit

Permalink
Issue/2285 (openfoodfacts#2330)
Browse files Browse the repository at this point in the history
* tests for issue 1466

* changes for issue 2285: make sure the 'not' logic for the second tag is used in the db query and reflected in the product title

* change the way title is constructed when there are 2 tags specified (openfoodfacts#1)

* rollback language changes for issue 2285 not needed now that stephane redid the product title with PR 1
  • Loading branch information
zigouras authored and stephanegigandet committed Sep 16, 2019
1 parent 0d4c995 commit c40a3ee
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is part of Product Opener.
# This file is part of Product Opener.
#
# Product Opener
# Copyright (C) 2011-2019 Association Open Food Facts
Expand Down Expand Up @@ -3405,20 +3405,25 @@ HTML
$products_title = sprintf(lang($tagtype . '_products'), $products_title);
}


if (defined $tagid2) {
$products_title .= lang("title_separator") . lang($tagtype2 . '_s') . separator_before_colon($lc) . ": " . $display_tag2;
$products_title .= lang("title_separator");
if ((defined $request_ref->{tag2_prefix}) and ($request_ref->{tag2_prefix} eq '-')) {
$products_title .= sprintf(lang($tagtype2 . '_without_products'), $display_tag2);
}
else {
$products_title .= sprintf(lang($tagtype2 . '_products'), $display_tag2);
}
}

if (not defined $request_ref->{groupby_tagtype}) {
if (defined $tagid2) {
$html .= "<p><a href=\"/" . $tag_type_plural{$tagtype}{$lc} . "\">" . ucfirst(lang($tagtype . '_p')) . "</a>" . separator_before_colon($lc)
$html .= "<p><a href=\"/" . $tag_type_plural{$tagtype}{$lc} . "\">" . ucfirst(lang($tagtype . '_s')) . "</a>" . separator_before_colon($lc)
. ": <a href=\"$newtagidpath\">$display_tag</a>"
. "\n<br><a href=\"/" . $tag_type_plural{$tagtype2}{$lc} . "\">" . ucfirst(lang($tagtype2 . '_p')) . "</a>" . separator_before_colon($lc)
. "\n<br><a href=\"/" . $tag_type_plural{$tagtype2}{$lc} . "\">" . ucfirst(lang($tagtype2 . '_s')) . "</a>" . separator_before_colon($lc)
. ": <a href=\"$newtagid2path\">$display_tag2</a></p>";
}
else {
$html .= "<p><a href=\"/" . $tag_type_plural{$tagtype}{$lc} . "\">" . ucfirst(lang($tagtype . '_p')) . "</a>" . separator_before_colon($lc). ": $display_tag</p>";
$html .= "<p><a href=\"/" . $tag_type_plural{$tagtype}{$lc} . "\">" . ucfirst(lang($tagtype . '_s')) . "</a>" . separator_before_colon($lc). ": $display_tag</p>";

my $tag_html .= display_tags_hierarchy_taxonomy($lc, $tagtype, [$canon_tagid]);

Expand All @@ -3441,19 +3446,23 @@ HTML



$html .= "<h2>" . $products_title . lang("title_separator") . display_taxonomy_tag($lc,"countries",$country) . "</h2>\n";
$html .= "<h2>" . $products_title . "</h2>\n";
}

} # end of if (defined $tagtype)

if ($country ne 'en:world') {

my $worlddom = format_subdomain('world');
my $word_link = "";
if (defined $request_ref->{groupby_tagtype}) {
$html .= "<p>&rarr; <a href=\"" . $worlddom . $request_ref->{world_current_link} . "\">" . lang('view_list_for_products_from_the_entire_world') . "</a></p>";
$word_link = lang('view_list_for_products_from_the_entire_world');
}
else {
$html .= "<p>&rarr; <a href=\"" . $worlddom . $request_ref->{world_current_link} . "\">" . lang('view_products_from_the_entire_world') . "</a></p>";
$word_link = lang('view_products_from_the_entire_world');
}
$html .= "<p>" . ucfirst(lang('countries_s')) . separator_before_colon($lc). ": " . display_taxonomy_tag($lc,"countries",$country) . " - "
. "<a href=\"" . $worlddom . $request_ref->{world_current_link} . "\">" . $word_link . "</a></p>";
}

my $query_ref = {};
Expand Down Expand Up @@ -3521,7 +3530,12 @@ HTML
$query_ref->{"\$or"} = [ { ($tagtype2 ) => undef}, { $tagtype2 => ""} ] ;
}
else {
$query_ref->{$field} = $value;
# issue 2285: second tag was not supporting the 'minus' query
if ((defined $request_ref->{tag2_prefix}) and ($request_ref->{tag2_prefix} eq '-')) {
$query_ref->{$field} = { "\$ne" => $value};
} else {
$query_ref->{$field} = $value;
}
}

}
Expand Down

0 comments on commit c40a3ee

Please sign in to comment.