Skip to content

Commit

Permalink
Merge branch 'master' into issue-4105/attributes-2
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanegigandet committed Sep 3, 2020
2 parents 0a35f49 + e2b4f21 commit 24259ea
Show file tree
Hide file tree
Showing 54 changed files with 8,288 additions and 1,949 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/containerimage.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
fetch-depth: 1
- name: Publish frontend image to Registry
uses: elgohr/Publish-Docker-Github-Action@2.19
uses: elgohr/Publish-Docker-Github-Action@2.20
with:
name: ${{ github.repository }}/frontend
username: ${{ github.actor }}
Expand All @@ -34,7 +34,7 @@ jobs:
rm icons.tar js.tar css.tar
docker rm -v $CONTAINER
- name: Publish backend image to Registry
uses: elgohr/Publish-Docker-Github-Action@2.19
uses: elgohr/Publish-Docker-Github-Action@2.20
with:
name: ${{ github.repository }}/backend
username: ${{ github.actor }}
Expand Down
27 changes: 26 additions & 1 deletion cgi/display.pl
Expand Up @@ -39,6 +39,21 @@
use Apache2::RequestRec ();
use Apache2::Const ();

# The nginx reverse proxy turns /somepath?someparam=somevalue to /cgi/display.pl?/somepath?someparam=somevalue
# so that all non /cgi/ queries are sent to display.pl and that we can get the path in the querty string
# CGI.pm thus adds somepath? at the start of the name of the first parameter.
# we need to remove it so that we can use the CGI.pm param() function to later access the parameters

my @params = param();
if (defined $params[0]) {
my $first_param = $params[0];
my $first_param_value = param($first_param);
$log->debug("replacing first param to remove path from parameter name", { first_param => $first_param, $first_param_value => $first_param_value });
CGI::delete($first_param);
$first_param =~ s/^(.*?)\?//;
param($first_param, $first_param_value);
}

ProductOpener::Display::init();

my %request = (
Expand All @@ -61,7 +76,17 @@
}

if (defined $request{api}) {
display_product_api(\%request);
if (param("api_method") eq "search") {
# /api/v0/search
display_tag(\%request);
}
else {
# /api/v0/product/[code] or a local name like /api/v0/produit/[code] so that we can easily add /api/v0/ to any product url
display_product_api(\%request);
}
}
elsif (defined $request{search}) {
display_tag(\%request);
}
elsif (defined $request{text}) {
display_text(\%request);
Expand Down
2 changes: 1 addition & 1 deletion cgi/search.pl
Expand Up @@ -84,7 +84,7 @@
}
}

my @search_fields = qw(brands categories packaging labels origins manufacturing_places emb_codes purchase_places stores countries ingredients additives allergens traces nutrition_grades nova_groups languages creator editors states );
my @search_fields = qw(brands categories packaging labels origins manufacturing_places emb_codes purchase_places stores countries ingredients additives allergens traces nutrition_grades nova_groups languages creator editors states);

$admin and push @search_fields, "lang";

Expand Down
16 changes: 10 additions & 6 deletions cgi/user.pl
Expand Up @@ -61,6 +61,8 @@

my $userid = get_fileid(param('userid'), 1);

$log->debug("user form - start", { type => $type, action => $action, userid => $userid, User_id => $User_id }) if $log->is_debug();

my $html = '';

my $user_ref = {};
Expand Down Expand Up @@ -100,7 +102,7 @@
ProductOpener::Users::check_edit_owner($user_ref, \@errors);
}
else {
ProductOpener::Users::check_user_form($user_ref, \@errors);
ProductOpener::Users::check_user_form($type, $user_ref, \@errors);
}

if ($#errors >= 0) {
Expand All @@ -118,6 +120,8 @@
$template_data_ref->{error_count} = $#errors;
$template_data_ref->{errors} = \@errors;

$log->debug("user form - before display / process", { type => $type, action => $action, userid => $userid }) if $log->is_debug();

if ($action eq 'display') {

$scripts .= <<SCRIPT
Expand All @@ -144,22 +148,21 @@
}
}

$template_data_ref->{display_user_form} = ProductOpener::Users::display_user_form($user_ref,\$scripts);
$template_data_ref->{display_user_form_optional} = ProductOpener::Users::display_user_form_optional($user_ref);
$template_data_ref->{display_user_form_admin_only} = ProductOpener::Users::display_user_form_admin_only($user_ref);
$template_data_ref->{display_user_form} = ProductOpener::Users::display_user_form($type, $user_ref,\$scripts);
$template_data_ref->{display_user_form_optional} = ProductOpener::Users::display_user_form_optional($type, $user_ref);
$template_data_ref->{display_user_form_admin_only} = ProductOpener::Users::display_user_form_admin_only($type, $user_ref);

$template_data_ref->{admin} = $admin;

}
elsif ($action eq 'process') {

if (($type eq 'add') or ($type =~ /^edit/)) {
ProductOpener::Users::process_user_form($user_ref);
ProductOpener::Users::process_user_form($type, $user_ref);
}
elsif ($type eq 'delete') {
ProductOpener::Users::delete_user($user_ref);
}
$template_data_ref->{type} = $type;

if ($type eq 'add') {

Expand All @@ -183,6 +186,7 @@

$template_data_ref->{debug} = $debug;
$template_data_ref->{userid} = $userid;
$template_data_ref->{type} = $type;

my $full_width = 1;
if ($action ne 'display') {
Expand Down

0 comments on commit 24259ea

Please sign in to comment.