Compare commits

4 Commits

Author SHA1 Message Date
giles
356d916e26 fix: correct endpoint name to market.browse.product.cart
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 00:40:55 +00:00
giles
a28424c07c fix: use url_for for cart/product URLs to include page/market slugs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 00:29:46 +00:00
giles
37ceb37b82 fix: add trailing slashes to cart URLs in product templates
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:55:01 +00:00
giles
0c9b8d6aa2 feat: add page_cart_url helper and update shared cart templates for Phase 4
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 21:46:50 +00:00
6 changed files with 18 additions and 17 deletions

View File

@@ -13,7 +13,7 @@ from suma_browser.app.csrf import generate_csrf_token
from suma_browser.app.authz import has_access
from suma_browser.app.filters import register as register_filters
from .urls import coop_url, market_url, cart_url, events_url, login_url
from .urls import coop_url, market_url, cart_url, events_url, login_url, page_cart_url
def setup_jinja(app: Quart) -> None:
@@ -93,6 +93,7 @@ def setup_jinja(app: Quart) -> None:
app.jinja_env.globals["cart_url"] = cart_url
app.jinja_env.globals["events_url"] = events_url
app.jinja_env.globals["login_url"] = login_url
app.jinja_env.globals["page_cart_url"] = page_cart_url
# register jinja filters
register_filters(app)

View File

@@ -37,10 +37,10 @@ def events_url(path: str = "/") -> str:
return app_url("events", path)
def market_url_for(post_slug: str, market_slug: str, path: str = "/") -> str:
def page_cart_url(page_slug: str, path: str = "/") -> str:
if not path.startswith("/"):
path = "/" + path
return market_url(f"/{post_slug}/{market_slug}{path}")
return cart_url(f"/{page_slug}{path}")
def login_url(next_url: str = "") -> str:

View File

@@ -103,7 +103,7 @@
{% if g.user %}
<form
method="post"
action="{{ url_for('cart.checkout')|host }}"
action="{{ url_for('page_cart.page_checkout')|host if page_post is defined and page_post else url_for('cart_global.checkout')|host }}"
class="w-full"
>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

View File

@@ -27,7 +27,7 @@
<div>
<a
href="{{ url_for('cart.view_cart')|host }}"
href="{{ cart_url('/') }}"
class="inline-flex items-center px-3 py-2 text-xs sm:text-sm rounded-full border border-stone-300 bg-white hover:bg-stone-50 transition"
>
<i class="fa fa-shopping-cart mr-2" aria-hidden="true"></i>

View File

@@ -1,7 +1,7 @@
{% import 'macros/links.html' as links %}
{% macro header_row(oob=False) %}
{% call links.menu_row(id='cart-row', oob=oob) %}
{% call links.link(url_for('cart.view_cart'), hx_select_search ) %}
{% call links.link(cart_url('/'), hx_select_search ) %}
<i class="fa fa-shopping-cart"></i>
<h2 class="text-xl font-bold">cart</h2>
{% endcall %}

View File

@@ -7,9 +7,9 @@
{% if not quantity %}
<form
action="{{ market_url('/product/' + slug + '/cart') }}"
action="{{ url_for('market.browse.product.cart', slug=slug) }}"
method="post"
hx-post="{{ market_url('/product/' + slug + '/cart') }}"
hx-post="{{ url_for('market.browse.product.cart', slug=slug) }}"
hx-target="#cart-mini"
hx-swap="outerHTML"
class="rounded flex items-center"
@@ -38,9 +38,9 @@
<div class="rounded flex items-center gap-2">
<!-- minus -->
<form
action="{{ market_url('/product/' + slug + '/cart') }}"
action="{{ url_for('market.browse.product.cart', slug=slug) }}"
method="post"
hx-post="{{ market_url('/product/' + slug + '/cart') }}"
hx-post="{{ url_for('market.browse.product.cart', slug=slug) }}"
hx-target="#cart-mini"
hx-swap="outerHTML"
>
@@ -80,9 +80,9 @@
<!-- plus -->
<form
action="{{ market_url('/product/' + slug + '/cart') }}"
action="{{ url_for('market.browse.product.cart', slug=slug) }}"
method="post"
hx-post="{{ market_url('/product/' + slug + '/cart') }}"
hx-post="{{ url_for('market.browse.product.cart', slug=slug) }}"
hx-target="#cart-mini"
hx-swap="outerHTML"
>
@@ -139,7 +139,7 @@
<div class="flex flex-col sm:flex-row sm:items-start justify-between gap-2 sm:gap-3">
<div class="min-w-0">
<h2 class="text-sm sm:text-base md:text-lg font-semibold text-stone-900">
{% set href=market_url('/product/' + p.slug + '/') %}
{% set href=url_for('market.browse.product.product_detail', slug=p.slug) %}
<a
href="{{ href }}"
hx_get="{{href}}"
@@ -189,9 +189,9 @@
<div class="flex items-center gap-2 text-xs sm:text-sm text-stone-700">
<span class="text-[0.65rem] sm:text-xs uppercase tracking-wide text-stone-500">Quantity</span>
<form
action="{{ market_url('/product/' + p.slug + '/cart') }}"
action="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
method="post"
hx-post="{{ market_url('/product/' + p.slug + '/cart') }}"
hx-post="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
hx-target="#cart-mini"
hx-swap="outerHTML"
>
@@ -212,9 +212,9 @@
{{ item.quantity }}
</span>
<form
action="{{ market_url('/product/' + p.slug + '/cart') }}"
action="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
method="post"
hx-post="{{ market_url('/product/' + p.slug + '/cart') }}"
hx-post="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
hx-target="#cart-mini"
hx-swap="outerHTML"
>