Remove extra cart header row from admin pages, use shared post header
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m21s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m21s
Cart admin pages (admin overview, payments) now use the same header pattern as blog/market/events: root_header → post_header → admin_header. The domain name appears via app_label on the root header instead of a separate level-1 "cart" row. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ from markupsafe import escape
|
|||||||
from shared.sexp.jinja_bridge import render, load_service_components
|
from shared.sexp.jinja_bridge import render, load_service_components
|
||||||
from shared.sexp.helpers import (
|
from shared.sexp.helpers import (
|
||||||
call_url, root_header_html, post_admin_header_html,
|
call_url, root_header_html, post_admin_header_html,
|
||||||
|
post_header_html as _shared_post_header_html,
|
||||||
search_desktop_html, search_mobile_html, full_page, oob_page,
|
search_desktop_html, search_mobile_html, full_page, oob_page,
|
||||||
)
|
)
|
||||||
from shared.infrastructure.urls import market_product_url, cart_url
|
from shared.infrastructure.urls import market_product_url, cart_url
|
||||||
@@ -25,6 +26,25 @@ load_service_components(os.path.dirname(os.path.dirname(__file__)))
|
|||||||
# Header helpers
|
# Header helpers
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def _ensure_post_ctx(ctx: dict, page_post: Any) -> dict:
|
||||||
|
"""Ensure ctx has a 'post' dict from page_post DTO (for shared post_header_html)."""
|
||||||
|
if ctx.get("post") or not page_post:
|
||||||
|
return ctx
|
||||||
|
ctx = {**ctx, "post": {
|
||||||
|
"id": getattr(page_post, "id", None),
|
||||||
|
"slug": getattr(page_post, "slug", ""),
|
||||||
|
"title": getattr(page_post, "title", ""),
|
||||||
|
"feature_image": getattr(page_post, "feature_image", None),
|
||||||
|
}}
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
def _post_header_html(ctx: dict, page_post: Any, *, oob: bool = False) -> str:
|
||||||
|
"""Build post-level header row from page_post DTO, using shared helper."""
|
||||||
|
ctx = _ensure_post_ctx(ctx, page_post)
|
||||||
|
return _shared_post_header_html(ctx, oob=oob)
|
||||||
|
|
||||||
|
|
||||||
def _cart_header_html(ctx: dict, *, oob: bool = False) -> str:
|
def _cart_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||||
"""Build the cart section header row."""
|
"""Build the cart section header row."""
|
||||||
return render(
|
return render(
|
||||||
@@ -727,6 +747,7 @@ def _cart_page_admin_header_html(ctx: dict, page_post: Any, *, oob: bool = False
|
|||||||
selected: str = "") -> str:
|
selected: str = "") -> str:
|
||||||
"""Build the page-level admin header row — delegates to shared helper."""
|
"""Build the page-level admin header row — delegates to shared helper."""
|
||||||
slug = page_post.slug if page_post else ""
|
slug = page_post.slug if page_post else ""
|
||||||
|
ctx = _ensure_post_ctx(ctx, page_post)
|
||||||
return post_admin_header_html(ctx, slug, oob=oob, selected=selected)
|
return post_admin_header_html(ctx, slug, oob=oob, selected=selected)
|
||||||
|
|
||||||
|
|
||||||
@@ -772,24 +793,16 @@ def _cart_payments_main_panel_html(ctx: dict) -> str:
|
|||||||
async def render_cart_admin_page(ctx: dict, page_post: Any) -> str:
|
async def render_cart_admin_page(ctx: dict, page_post: Any) -> str:
|
||||||
"""Full page: cart page admin overview."""
|
"""Full page: cart page admin overview."""
|
||||||
content = _cart_admin_main_panel_html(ctx)
|
content = _cart_admin_main_panel_html(ctx)
|
||||||
hdr = root_header_html(ctx)
|
root_hdr = root_header_html(ctx)
|
||||||
child = _page_cart_header_html(ctx, page_post) + _cart_page_admin_header_html(ctx, page_post)
|
post_hdr = _post_header_html(ctx, page_post)
|
||||||
hdr += render("cart-header-child-nested",
|
admin_hdr = _cart_page_admin_header_html(ctx, page_post)
|
||||||
outer_html=_cart_header_html(ctx), inner_html=child)
|
return full_page(ctx, header_rows_html=root_hdr + post_hdr + admin_hdr, content_html=content)
|
||||||
return full_page(ctx, header_rows_html=hdr, content_html=content)
|
|
||||||
|
|
||||||
|
|
||||||
async def render_cart_admin_oob(ctx: dict, page_post: Any) -> str:
|
async def render_cart_admin_oob(ctx: dict, page_post: Any) -> str:
|
||||||
"""OOB response: cart page admin overview."""
|
"""OOB response: cart page admin overview."""
|
||||||
content = _cart_admin_main_panel_html(ctx)
|
content = _cart_admin_main_panel_html(ctx)
|
||||||
oobs = (
|
oobs = _cart_page_admin_header_html(ctx, page_post, oob=True)
|
||||||
_cart_page_admin_header_html(ctx, page_post, oob=True)
|
|
||||||
+ render("cart-header-child-oob",
|
|
||||||
inner_html=_page_cart_header_html(ctx, page_post)
|
|
||||||
+ _cart_page_admin_header_html(ctx, page_post))
|
|
||||||
+ _cart_header_html(ctx, oob=True)
|
|
||||||
+ root_header_html(ctx, oob=True)
|
|
||||||
)
|
|
||||||
return oob_page(ctx, oobs_html=oobs, content_html=content)
|
return oob_page(ctx, oobs_html=oobs, content_html=content)
|
||||||
|
|
||||||
|
|
||||||
@@ -800,26 +813,16 @@ async def render_cart_admin_oob(ctx: dict, page_post: Any) -> str:
|
|||||||
async def render_cart_payments_page(ctx: dict, page_post: Any) -> str:
|
async def render_cart_payments_page(ctx: dict, page_post: Any) -> str:
|
||||||
"""Full page: payments config."""
|
"""Full page: payments config."""
|
||||||
content = _cart_payments_main_panel_html(ctx)
|
content = _cart_payments_main_panel_html(ctx)
|
||||||
hdr = root_header_html(ctx)
|
root_hdr = root_header_html(ctx)
|
||||||
|
post_hdr = _post_header_html(ctx, page_post)
|
||||||
admin_hdr = _cart_page_admin_header_html(ctx, page_post, selected="payments")
|
admin_hdr = _cart_page_admin_header_html(ctx, page_post, selected="payments")
|
||||||
child = _page_cart_header_html(ctx, page_post) + admin_hdr
|
return full_page(ctx, header_rows_html=root_hdr + post_hdr + admin_hdr, content_html=content)
|
||||||
hdr += render("cart-header-child-nested",
|
|
||||||
outer_html=_cart_header_html(ctx), inner_html=child)
|
|
||||||
return full_page(ctx, header_rows_html=hdr, content_html=content)
|
|
||||||
|
|
||||||
|
|
||||||
async def render_cart_payments_oob(ctx: dict, page_post: Any) -> str:
|
async def render_cart_payments_oob(ctx: dict, page_post: Any) -> str:
|
||||||
"""OOB response: payments config."""
|
"""OOB response: payments config."""
|
||||||
content = _cart_payments_main_panel_html(ctx)
|
content = _cart_payments_main_panel_html(ctx)
|
||||||
admin_hdr = _cart_page_admin_header_html(ctx, page_post, selected="payments")
|
oobs = _cart_page_admin_header_html(ctx, page_post, oob=True, selected="payments")
|
||||||
oobs = (
|
|
||||||
_cart_page_admin_header_html(ctx, page_post, oob=True, selected="payments")
|
|
||||||
+ render("cart-header-child-oob",
|
|
||||||
inner_html=_page_cart_header_html(ctx, page_post)
|
|
||||||
+ admin_hdr)
|
|
||||||
+ _cart_header_html(ctx, oob=True)
|
|
||||||
+ root_header_html(ctx, oob=True)
|
|
||||||
)
|
|
||||||
return oob_page(ctx, oobs_html=oobs, content_html=content)
|
return oob_page(ctx, oobs_html=oobs, content_html=content)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user