[IMP] website_sale_aplicoop: readable slug in the group order URL
Group order pages were published under their database id (`/eskaera/1`), which says nothing to the member opening the link. `group.order` gains a `slug` field and the public pages move to `/eskaera/<slug>` (e.g. `/eskaera/escola-fructuos`). The slug is generated from the order name on creation, is unique, and can be edited under the name on the form; emptying it regenerates it from the current name. Values that would make the order unreachable are rejected: a plain number (the legacy numeric URLs win that match) and the static routes served under `/eskaera/` (`labels`, `save-order`, `i18n`, ...). `/eskaera/<id>` and `/eskaera/<id>/checkout` are kept as redirects to their slug URL, so the links already shared with members keep working. The AJAX endpoints (`load-page`, `save-order`, `confirm`, ...) stay numeric: they never show up in the address bar. Consequently the frontend now reads the order id from the `data-order-id` attribute only, as the URL no longer carries it. The post-migration script fills the slug of the orders that already existed. Renaming the `/eskaera` prefix itself (`/escolas` for a schools deployment) needs no code: a *308 Redirect / Rewrite* rule per public route in Website > Configuration > Redirects serves the pages on the new prefix, rewrites the links in the templates and redirects the old URLs, per website. Documented in `readme/CONFIGURE.rst`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2b1cabbb43
commit
23edee6154
14 changed files with 463 additions and 28 deletions
|
|
@ -73,16 +73,12 @@
|
|||
var cartContainer = document.getElementById("cart-items-container");
|
||||
var orderIdElement = confirmBtn || cartContainer;
|
||||
|
||||
// The URL is not a fallback here: it carries the slug of the order,
|
||||
// not its id.
|
||||
if (orderIdElement) {
|
||||
this.orderId = orderIdElement.getAttribute("data-order-id");
|
||||
}
|
||||
|
||||
// If still not found, try to extract from URL
|
||||
if (!this.orderId) {
|
||||
var urlMatch = window.location.pathname.match(/\/eskaera\/(\d+)/);
|
||||
this.orderId = urlMatch ? urlMatch[1] : null;
|
||||
}
|
||||
|
||||
console.log("[HomeDelivery] orderId resolved:", this.orderId);
|
||||
|
||||
// Handle checkbox (only exists on checkout page)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,9 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
// Get the order ID from the data attribute or from the URL
|
||||
// Get the order ID from the data attribute. It cannot be read from
|
||||
// the URL: that one carries the slug of the order, not its id.
|
||||
this.orderId = orderIdElement.getAttribute("data-order-id");
|
||||
if (!this.orderId) {
|
||||
var urlMatch = window.location.pathname.match(/\/eskaera\/(\d+)/);
|
||||
this.orderId = urlMatch ? urlMatch[1] : null;
|
||||
}
|
||||
|
||||
if (!this.orderId) {
|
||||
console.error("Order ID not found");
|
||||
|
|
@ -757,7 +754,7 @@
|
|||
// Map of href patterns to label keys
|
||||
var hrefPatterns = [
|
||||
{ pattern: /\/checkout$/, labelKey: "proceed_to_checkout" },
|
||||
{ pattern: /\/eskaera\/\d+$/, labelKey: "back_to_cart" },
|
||||
{ pattern: /\/eskaera\/[^/]+$/, labelKey: "back_to_cart" },
|
||||
];
|
||||
|
||||
// Find all elements with data-bs-toggle="tooltip"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue