Skip to content

Commit

Permalink
feat(producers): add link to admin manual on session sucess
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel committed Jan 7, 2022
1 parent 696c661 commit 88899b1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions cgi/session.pl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
if (defined $User_id) {

$template_data_ref->{user_name} = $User{name};
$template_data_ref->{is_admin} = is_admin_user($User_id);
$template_data_ref->{server_options_producers} = $server_options{producers_platform};

my $next_action = param('next_action');
Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ sub init()

# %admin is defined in Config.pm
# admins can change permissions for all users
if ((%admins) and (defined $User_id) and (exists $admins{$User_id})) {
if (is_admin_user($User_id)) {
$admin = 1;
}

Expand Down
14 changes: 14 additions & 0 deletions lib/ProductOpener/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ BEGIN
&userpath
&create_user
&is_admin_user
&create_password_hash
&check_password_hash
Expand Down Expand Up @@ -197,6 +198,19 @@ sub delete_user($) {
find_and_replace_user_id_in_products($userid, $new_userid);
}

=head2 is_admin_user($user_id)
Simply tells if a user is an admin of the platform
=cut
sub is_admin_user($) {
my $user_id = shift;

# %admin is defined in Config.pm
# admins can change permissions for all users
return (%admins) and (defined $user_id) and (exists $admins{$user_id});
}


sub display_user_form($$$) {

Expand Down
4 changes: 4 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ msgctxt "you_can_also_help_us"
msgid "You can also help to fund the Open Food Facts project"
msgstr "You can also help to fund the Open Food Facts project"

msgctxt "producers_administration_manual"
msgid "Producers Admin manual"
msgstr "Producers Admin manual"

msgctxt "bottom_content"
msgid "<a href=\"https://world.openfoodfacts.org/donate-to-open-food-facts\"><img src=\"https://static.openfoodfacts.org/images/svg/donate-icon.svg\" alt=\"Donate to Open Food Facts\" /></a><p><<site_name>> is made by a non-profit association, independent from the industry. It is made for all, by all, and it is funded by all. You can support our work by <a href=\"https://world.openfoodfacts.org/donate-to-open-food-facts\">donating to Open Food Facts</a> and also by <a href=\"https://www.lilo.org/fr/open-food-facts/?utm_source=open-food-facts\">using the Lilo search engine</a>.<br/><b>Thank you!</b></p>"
msgstr "<a href=\"https://world.openfoodfacts.org/donate-to-open-food-facts\"><img src=\"https://static.openfoodfacts.org/images/svg/donate-icon.svg\" alt=\"Donate to Open Food Facts\" /></a><p><<site_name>> is made by a non-profit association, independent from the industry. It is made for all, by all, and it is funded by all. You can support our work by <a href=\"https://world.openfoodfacts.org/donate-to-open-food-facts\">donating to Open Food Facts</a> and also by <a href=\"https://www.lilo.org/fr/open-food-facts/?utm_source=open-food-facts\">using the Lilo search engine</a>.<br/><b>Thank you!</b></p>"
Expand Down
4 changes: 4 additions & 0 deletions po/common/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ msgctxt "you_can_also_help_us"
msgid "You can also help to fund the Open Food Facts project"
msgstr "Vous pouvez aussi nous aider 脿 financer le projet Open Food Facts"

msgctxt "producers_administration_manual"
msgid "Producers Admin manual"
msgstr "Manuel d'administration de la plateforme producteurs"

msgctxt "bottom_content"
msgid "<a href=\"https://world.openfoodfacts.org/donate-to-open-food-facts\"><img src=\"https://static.openfoodfacts.org/images/svg/donate-icon.svg\" alt=\"Donate to Open Food Facts\" /></a><p><<site_name>> is made by a non-profit association, independent from the industry. It is made for all, by all, and it is funded by all. You can support our work by <a href=\"https://world.openfoodfacts.org/donate-to-open-food-facts\">donating to Open Food Facts</a> and also by <a href=\"https://www.lilo.org/fr/open-food-facts/?utm_source=open-food-facts\">using the Lilo search engine</a>.<br/><b>Thank you!</b></p>"
msgstr "<a href=\"https://fr.openfoodfacts.org/faire-un-don-a-open-food-facts\"><img src=\"https://static.openfoodfacts.org/images/svg/donate-icon.svg\" alt=\"Donate to Open Food Facts\" /></a><p><<site_name>> est d茅velopp茅 par une association 脿 but non lucratif ind茅pendante de l'industrie. Open Food Facts est fait pour tous, par tous, et est financ茅 par tous. Vous pouvez soutenir notre travail en <a href=\"https://fr.openfoodfacts.org/faire-un-don-a-open-food-facts\">donnant 脿 Open Food Facts</a> et aussi en utilisant le <a href=\"https://www.lilo.org/fr/open-food-facts/?utm_source=open-food-facts\">moteur de recherche Lilo</a>.<br/><b>Merci beaucoup !</b></p>"
Expand Down
8 changes: 8 additions & 0 deletions templates/web/pages/session/session.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ <h3>[% lang('you_can_also_help_us') %]</h3>
<p>[% lang('bottom_content') %]</p>
[% END %]

[% IF is_admin and server_options_producers %]
<p>
<a href="https://docs.google.com/document/d/106LAPvseRcMA_6mBj0uNXZcEDiiCKWH9SKzg0JMeg0w/edit">
[% lang('producers_administration_manual') %]
</a>
</p>
[% END %]

[% ELSE %]

<p>[% lang('goodbye') %]</p>
Expand Down

0 comments on commit 88899b1

Please sign in to comment.