All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 11m37s
Rename all sexp directories, files, identifiers, and references to sx. artdag/ excluded (separate media processing DSL). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""Orders app fragment endpoints.
|
|
|
|
Fragments:
|
|
account-nav-item "orders" link for account dashboard
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from quart import Blueprint, Response, request
|
|
from shared.infrastructure.fragments import FRAGMENT_HEADER
|
|
|
|
|
|
def register():
|
|
bp = Blueprint("fragments", __name__, url_prefix="/internal/fragments")
|
|
|
|
async def _account_nav_item():
|
|
from shared.infrastructure.urls import orders_url
|
|
from shared.sx.helpers import sx_call
|
|
|
|
return sx_call("account-nav-item",
|
|
href=orders_url("/"),
|
|
label="orders")
|
|
|
|
_handlers = {
|
|
"account-nav-item": _account_nav_item,
|
|
}
|
|
|
|
@bp.before_request
|
|
async def _require_fragment_header():
|
|
if not request.headers.get(FRAGMENT_HEADER):
|
|
return Response("", status=403)
|
|
|
|
@bp.get("/<fragment_type>")
|
|
async def get_fragment(fragment_type: str):
|
|
handler = _handlers.get(fragment_type)
|
|
if handler is None:
|
|
return Response("", status=200, content_type="text/sx")
|
|
src = await handler()
|
|
return Response(src, status=200, content_type="text/sx")
|
|
|
|
return bp
|