Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display orgs data in table #10433

58 changes: 58 additions & 0 deletions cgi/display_org_table.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/perl -w

# 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 <https://www.gnu.org/licenses/>.

use ProductOpener::PerlStandards;

use CGI::Carp qw(fatalsToBrowser);
use ProductOpener::Config qw/:all/;
use ProductOpener::Display qw/:all/;
use ProductOpener::Lang qw/:all/;
use ProductOpener::Data qw/:all/;
use ProductOpener::Users qw/$User_id %User/;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();

my $orgs_collection = get_orgs_collection();
my @orgs = $orgs_collection->find->all;

my $template_data_ref = {orgs => \@orgs};

if ((not defined $User_id)) {
$log->debug("undefined user", {User_id => $User_id}) if $log->is_debug();
display_error_and_exit($request_ref, $Lang{error_no_permission}{$lc}, 401);
}

if ((not $admin) or (not $User{pro_moderator})) {
$log->debug("user does not have permission to view organisation list", {User_id => $User_id}) if $log->is_debug();
display_error_and_exit($request_ref, $Lang{error_no_permission}{$lc}, 403);
}

my $html;
process_template('web/pages/dashboard/display_orgs_table.tt.html', $template_data_ref, \$html) or $html = '';
if ($tt->error()) {
$html .= '<p>' . $tt->error() . '</p>';
}

$request_ref->{title} = "Organization List";
$request_ref->{content_ref} = \$html;
display_page($request_ref);
50 changes: 50 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6984,6 +6984,56 @@ msgctxt "knowledge_panels_ingredients_rare_crops_what_you_can_do_list_5"
msgid "and your health!"
msgstr "and your health!"

msgctxt "brands_example_beauty"
msgid "Nivea, Nivea Men"
msgstr "Nivea, Nivea Men"

msgctxt "categories_example_beauty"
msgid "Anti-dandruff shampoo, Whitening toothpaste"
msgstr "Anti-dandruff shampoo, Whitening toothpaste"

msgctxt "emb_codes_example_beauty"
msgid "EMB 53062"
msgstr "EMB 53062"

msgctxt "generic_name_example_beauty"
msgid "Anti-dandruff shampoo"
msgstr "Anti-dandruff shampoo"

msgctxt "product_name_example_beauty"
msgid "Anti-Perspirant Stress Protect"
msgstr "Anti-Perspirant Stress Protect"

msgctxt "ingredients_text_example_beauty"
msgid "AQUA/WATER, SODIUM LAURETH SULFATE, DISODIUM COCOAMPHODIACETATE, GLYCOL DISTEARATE, COCAMIDE MEA"
msgstr "AQUA/WATER, SODIUM LAURETH SULFATE, DISODIUM COCOAMPHODIACETATE, GLYCOL DISTEARATE, COCAMIDE MEA"

msgctxt "report_problem_navigation"
msgid "Report a problem"
msgstr "Report a problem"

msgctxt "created_by"
msgid "Created by"
msgstr "Created by"

msgctxt "org_id"
msgid "Org id"
msgstr "Org id"

msgctxt "verified_status"
msgid "Verified status"
msgstr "Verified status"

msgctxt "creation_date"
msgid "Creation date"
msgstr "Creation date"

msgctxt "knowledge_panels_ingredients_rare_crops_divinfood"
msgid "Open Food Facts participates in the European project <a href=\"https://divinfood.eu/\">DIVINFOOD</a> (funded from European Union’s Horizon 2020 research and innovation programme). DIVINFOOD aims to develop food chains that value under-utilised agrobiodiversity in order to act against the decline of biodiversity and to meet the growing expectations of consumers for healthy, local products that contribute to sustainable food systems."
msgstr "Open Food Facts participates in the European project <a href=\"https://divinfood.eu/\">DIVINFOOD</a> (funded from European Union’s Horizon 2020 research and innovation programme). DIVINFOOD aims to develop food chains that value under-utilised agrobiodiversity in order to act against the decline of biodiversity and to meet the growing expectations of consumers for healthy, local products that contribute to sustainable food systems."

msgctxt "open_in_crm"
msgid "Open in CRM"
msgstr "Open in CRM"


16 changes: 16 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -6926,6 +6926,22 @@ msgctxt "report_problem_navigation"
msgid "Report a problem"
msgstr "Report a problem"

msgctxt "created_by"
msgid "Created by"
msgstr "Created by"

msgctxt "org_id"
msgid "Org id"
msgstr "Org id"

msgctxt "verified_status"
msgid "Verified status"
msgstr "Verified status"

msgctxt "creation_date"
msgid "Creation date"
msgstr "Creation date"

msgctxt "enter_main_contact_username"
msgid "Enter main contact's username :"
msgstr "Enter main contact's username :"
Expand Down
15 changes: 15 additions & 0 deletions po/common/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6920,3 +6920,18 @@ msgctxt "report_problem_navigation"
msgid "Signaler un problème"
msgstr "Signaler un problème"

msgctxt "created_by"
msgid "Créé par"
msgstr "Créé par"

msgctxt "org_id"
msgid "Org id"
msgstr "Org id"

msgctxt "verified_status"
msgid "Statut vérifié"
msgstr "Statut vérifié"

msgctxt "creation_date"
msgid "Date de création"
msgstr "Date de création"
15 changes: 15 additions & 0 deletions po/common/yo.po
Original file line number Diff line number Diff line change
Expand Up @@ -6895,3 +6895,18 @@ msgctxt "report_problem_navigation"
msgid "Report a problem"
msgstr ""

msgctxt "created_by"
msgid "Ẹlẹ́dàá"
msgstr "Ẹlẹ́dàá"

msgctxt "org_id"
msgid "Ìdánimọ̀ ęgbẹ́"
msgstr "Ìdánimọ̀ ęgbẹ́"

msgctxt "verified_status"
msgid "Ipò ìfẹ̀hónúhàn"
msgstr "Ipò ìfẹ̀hónúhàn"

msgctxt "creation_date"
msgid "Ọjọ́ tí a dá"
msgstr "Ọjọ́ tí a dá"
32 changes: 32 additions & 0 deletions templates/web/pages/dashboard/display_orgs_table.tt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- start templates/[% template.name %] -->

<div style="position:relative">
<table>
<thead>
<tr>
<th>[% lang("serial_no") %]</th>
<th>[% lang("name") %]</th>
<th>[% lang("created_by") %]</th>
<th>[% lang("org_id") %]</th>
<th>[% lang("verified_status") %]</th>
<th>[% lang("creation_date") %]</th>
</tr>
</thead>
<tbody>
[% SET count = 1 %]
[% FOREACH org IN orgs %]
<tr>
<td>[% count %].</td>
<td>[% org.name %]</td>
<td>[% org.creator %]</td>
<td>[% org.org_id %]</td>
<td>[% IF org.validated == 0 %]false[% ELSE %]true[% END %]</td>
<td>[% display_date_tag(org.created_t) %]</td>
</tr>
[% SET count = count + 1 %]
[% END %]
</tbody>
</table>
</div>

<!-- end templates/[% template.name %] -->
Loading