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: add /org/[orgid] facet in pro platform URL #10432

Merged
merged 26 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cgi/product_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,8 @@ ($product_ref, $field, $language)
display_product(\%request);
}

$template_data_ref_process->{edited_product_url} = $url_prefix . product_url($product_ref);
$template_data_ref_process->{edited_product_url}
= $url_prefix . get_org_id_pretty_path() . product_url($product_ref);
$template_data_ref_process->{edit_product_url} = $url_prefix . product_action_url($product_ref->{code}, "");

if ($type ne 'delete') {
Expand Down
2 changes: 1 addition & 1 deletion cgi/user.pl
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
$log->info("redirecting to / after changing owner", {}) if $log->is_info();

my $r = shift;
$r->headers_out->set(Location => "/");
$r->headers_out->set(Location => "/org/$User{pro_moderator_owner}");
$r->status(302);
return 302;
}
Expand Down
32 changes: 28 additions & 4 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ BEGIN {
$knowledge_panels_options_ref

&display_nutriscore_calculation_details_2021
&get_org_id_pretty_path

); # symbols to export on request
%EXPORT_TAGS = (all => [@EXPORT_OK]);
}
Expand Down Expand Up @@ -180,9 +182,18 @@ use ProductOpener::Cache qw/$max_memcached_object_size $memd generate_cache_key/
use ProductOpener::Permissions qw/has_permission/;
use ProductOpener::ProductsFeatures qw(feature_enabled);

use ProductOpener::Index qw/:all/;
use ProductOpener::Display qw/:all/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need those lines? Especially Display as we are in Display.pm
a lot of those modules are already imported above

use ProductOpener::Users qw/:all/;
use ProductOpener::Lang qw/$lc %Lang lang/;
use ProductOpener::Orgs qw/:all/;
use ProductOpener::Tags qw/canonicalize_tag_link/;
use ProductOpener::Text qw/remove_tags_and_quote/;

use Encode;
use URI::Escape::XS;
use CGI qw(:cgi :cgi-lib :form escapeHTML');
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:cgi :cgi-lib :form escapeHTML charset);
use HTML::Entities;
use DateTime;
use DateTime::Locale;
Expand Down Expand Up @@ -1289,6 +1300,7 @@ sub display_index_for_producer ($request_ref) {
# Display a message if some product updates have not been published yet
# Updates can also be on obsolete products

$template_data_ref->{org_id_pretty_path} = get_org_id_pretty_path();
$template_data_ref->{count_to_be_exported} = count_products({}, {states_tags => "en:to-be-exported"});
$template_data_ref->{count_obsolete_to_be_exported} = count_products({}, {states_tags => "en:to-be-exported"}, 1);

Expand Down Expand Up @@ -5320,8 +5332,7 @@ sub search_and_display_products ($request_ref, $query_ref, $sort_by, $limit, $pa

# Add a url field to the product, with the subdomain and path
my $url_path = product_url($product_ref);
$product_ref->{url} = $formatted_subdomain . $url_path;

$product_ref->{url} = $formatted_subdomain . get_org_id_pretty_path() . $url_path;
# Compute HTML to display the small front image, currently embedded in the HTML of web queries
if (not $api) {
$product_ref->{image_front_small_html} = display_image_thumb($product_ref, 'front');
Expand Down Expand Up @@ -5467,7 +5478,7 @@ sub search_and_display_products ($request_ref, $query_ref, $sort_by, $limit, $pa

push @{$template_data_ref->{current_drilldown_fields}},
{
current_link => $request_ref->{current_link},
current_link => get_org_id_pretty_path() . $request_ref->{current_link},
tag_type_plural => $tag_type_plural{$newtagtype}{$lc},
=> $,
tagtype => $newtagtype,
Expand Down Expand Up @@ -11546,4 +11557,17 @@ sub data_to_display_image ($product_ref, $imagetype, $target_lc) {
return $image_ref;
}

=head2 get_org_id_pretty_path ()

Returns the pretty path for the organization page
or an empty string if not on the producers platform.

/org/[orgid]

=cut

sub get_org_id_pretty_path () {
return $server_options{producers_platform} ? "/org/$Org_id" : "";
}

1;
2 changes: 2 additions & 0 deletions lib/ProductOpener/LoadData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use ProductOpener::ForestFootprint qw/load_forest_footprint_data/;
use ProductOpener::Ecoscore qw(load_agribalyse_data load_ecoscore_data);
use ProductOpener::MainCountries qw(load_scans_data);
use ProductOpener::NutritionCiqual qw(load_ciqual_data);
use ProductOpener::Routing qw(load_routes);
use ProductOpener::CRM qw(init_crm_data);

=head1 FUNCTIONS
Expand Down Expand Up @@ -83,6 +84,7 @@ sub load_data() {
init_geocode_addresses();
init_packaging_taxonomies_regexps();
load_scans_data();
load_routes();

if ((defined $options{product_type}) and ($options{product_type} eq "food")) {
load_agribalyse_data();
Expand Down
Loading
Loading