feat: restructure market app with per-market URL scoping
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 41s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 41s
- URL structure changes from /<route> to /<market_slug>/<route> - Root / shows markets listing page - app.py: url_value_preprocessor, url_defaults, hydrate_market (events app pattern) - Browse queries (db_nav, db_products_nocounts, db_products_counts) accept market_id - _productInfo reads g.market.id to scope all queries - save_nav accepts market_id, sets on new NavTop rows - API save_nav passes g.market.id - Scraper default URLs point to /suma-market/ on port 8001 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,14 +37,9 @@ def register():
|
||||
async def home():
|
||||
"""
|
||||
Market landing page.
|
||||
Shows the Ghost CMS post with slug='market'.
|
||||
Uses the post data hydrated by the app-level before_request (g.post_data).
|
||||
"""
|
||||
from shared.internal_api import get as api_get
|
||||
|
||||
# Fetch the market post from coop internal API
|
||||
p_data = await api_get("coop", "/internal/post/market")
|
||||
if not p_data:
|
||||
abort(404)
|
||||
p_data = getattr(g, "post_data", None) or {}
|
||||
|
||||
# Determine which template to use based on request type
|
||||
if not is_htmx_request():
|
||||
@@ -63,7 +58,9 @@ def register():
|
||||
Browse all products across all categories.
|
||||
Renders full page or just product cards (HTMX pagination fragment).
|
||||
"""
|
||||
nav = await get_nav(g.s)
|
||||
market = getattr(g, "market", None)
|
||||
market_id = market.id if market else None
|
||||
nav = await get_nav(g.s, market_id=market_id)
|
||||
ctx = {
|
||||
"category_label": "All Products",
|
||||
"top_slug": "all",
|
||||
@@ -102,7 +99,9 @@ def register():
|
||||
if is_category_blocked(top_slug):
|
||||
abort(404)
|
||||
|
||||
nav = await get_nav(g.s)
|
||||
market = getattr(g, "market", None)
|
||||
market_id = market.id if market else None
|
||||
nav = await get_nav(g.s, market_id=market_id)
|
||||
ctx = category_context(top_slug, None, nav)
|
||||
|
||||
product_info = await _productInfo(top_slug)
|
||||
@@ -136,7 +135,9 @@ def register():
|
||||
if is_category_blocked(top_slug, sub_slug):
|
||||
abort(404)
|
||||
|
||||
nav = await get_nav(g.s)
|
||||
market = getattr(g, "market", None)
|
||||
market_id = market.id if market else None
|
||||
nav = await get_nav(g.s, market_id=market_id)
|
||||
ctx = category_context(top_slug, sub_slug, nav)
|
||||
|
||||
product_info = await _productInfo(top_slug, sub_slug)
|
||||
|
||||
Reference in New Issue
Block a user