Phase 4: add container-nav fragment handler for market links
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s
Market app serves marketplace links as a fragment at /internal/fragments/container-nav for consumption by blog and events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,9 +6,10 @@ by other coop apps via the fragment client.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from quart import Blueprint, Response, request
|
||||
from quart import Blueprint, Response, g, render_template, request
|
||||
|
||||
from shared.infrastructure.fragments import FRAGMENT_HEADER
|
||||
from shared.services.registry import services
|
||||
|
||||
|
||||
def register():
|
||||
@@ -29,6 +30,25 @@ def register():
|
||||
html = await handler()
|
||||
return Response(html, status=200, content_type="text/html")
|
||||
|
||||
# --- container-nav fragment: market links --------------------------------
|
||||
|
||||
async def _container_nav_handler():
|
||||
container_type = request.args.get("container_type", "page")
|
||||
container_id = int(request.args.get("container_id", 0))
|
||||
post_slug = request.args.get("post_slug", "")
|
||||
|
||||
markets = await services.market.marketplaces_for_container(
|
||||
g.s, container_type, container_id,
|
||||
)
|
||||
if not markets:
|
||||
return ""
|
||||
return await render_template(
|
||||
"fragments/container_nav_markets.html",
|
||||
markets=markets, post_slug=post_slug,
|
||||
)
|
||||
|
||||
_handlers["container-nav"] = _container_nav_handler
|
||||
|
||||
bp._fragment_handlers = _handlers
|
||||
|
||||
return bp
|
||||
|
||||
Reference in New Issue
Block a user