fix: rename post slug URL param to page_slug to avoid collision
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 39s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 39s
The market blueprint already uses <slug> for product routes, so the app-level prefix uses <page_slug> instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
app.py
12
app.py
@@ -54,27 +54,27 @@ def create_app() -> "Quart":
|
|||||||
app.jinja_loader,
|
app.jinja_loader,
|
||||||
])
|
])
|
||||||
|
|
||||||
# Market blueprint nested under post slug: /<slug>/<market_slug>/
|
# Market blueprint nested under post slug: /<page_slug>/<market_slug>/
|
||||||
app.register_blueprint(
|
app.register_blueprint(
|
||||||
register_market_bp(
|
register_market_bp(
|
||||||
url_prefix="/",
|
url_prefix="/",
|
||||||
title=config()["coop_title"],
|
title=config()["coop_title"],
|
||||||
),
|
),
|
||||||
url_prefix="/<slug>/<market_slug>",
|
url_prefix="/<page_slug>/<market_slug>",
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- Auto-inject slug and market_slug into url_for() calls ---
|
# --- Auto-inject page_slug and market_slug into url_for() calls ---
|
||||||
@app.url_value_preprocessor
|
@app.url_value_preprocessor
|
||||||
def pull_slugs(endpoint, values):
|
def pull_slugs(endpoint, values):
|
||||||
if values:
|
if values:
|
||||||
if "slug" in values:
|
if "page_slug" in values:
|
||||||
g.post_slug = values.pop("slug")
|
g.post_slug = values.pop("page_slug")
|
||||||
if "market_slug" in values:
|
if "market_slug" in values:
|
||||||
g.market_slug = values.pop("market_slug")
|
g.market_slug = values.pop("market_slug")
|
||||||
|
|
||||||
@app.url_defaults
|
@app.url_defaults
|
||||||
def inject_slugs(endpoint, values):
|
def inject_slugs(endpoint, values):
|
||||||
for attr, param in [("post_slug", "slug"), ("market_slug", "market_slug")]:
|
for attr, param in [("post_slug", "page_slug"), ("market_slug", "market_slug")]:
|
||||||
val = g.get(attr)
|
val = g.get(attr)
|
||||||
if val and param not in values:
|
if val and param not in values:
|
||||||
if app.url_map.is_endpoint_expecting(endpoint, param):
|
if app.url_map.is_endpoint_expecting(endpoint, param):
|
||||||
|
|||||||
Reference in New Issue
Block a user