Move payments admin from events to cart service
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m40s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m40s
Payments config (SumUp credentials per page) is a cart concern since all checkouts go through the cart service. Moves it from events.rose-ash.com to cart.rose-ash.com/<page_slug>/admin/payments/ and adds a cart admin overview page at /<page_slug>/admin/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -721,3 +721,126 @@ async def render_checkout_error_page(ctx: dict, error: str | None = None, order:
|
||||
filt = _checkout_error_filter_html()
|
||||
content = _checkout_error_content_html(error, order)
|
||||
return full_page(ctx, header_rows_html=hdr, filter_html=filt, content_html=content)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Page admin (/<page_slug>/admin/)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _cart_page_admin_header_html(ctx: dict, page_post: Any, *, oob: bool = False) -> str:
|
||||
"""Build the page-level admin header row."""
|
||||
from quart import url_for
|
||||
link_href = url_for("page_admin.admin")
|
||||
return render("menu-row", id="page-admin-row", level=2, colour="sky",
|
||||
link_href=link_href, link_label="admin", icon="fa fa-cog",
|
||||
child_id="page-admin-header-child", oob=oob)
|
||||
|
||||
|
||||
def _cart_payments_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
"""Build the payments section header row."""
|
||||
from quart import url_for
|
||||
link_href = url_for("page_admin.payments")
|
||||
return render("menu-row", id="payments-row", level=3, colour="sky",
|
||||
link_href=link_href, link_label="Payments",
|
||||
icon="fa fa-credit-card",
|
||||
child_id="payments-header-child", oob=oob)
|
||||
|
||||
|
||||
def _cart_admin_main_panel_html(ctx: dict) -> str:
|
||||
"""Admin overview panel — links to sub-admin pages."""
|
||||
from quart import url_for
|
||||
payments_href = url_for("page_admin.payments")
|
||||
return (
|
||||
'<div id="main-panel">'
|
||||
'<div class="flex items-center justify-between p-3 border-b">'
|
||||
'<span class="font-medium"><i class="fa fa-credit-card text-purple-600 mr-1"></i> Payments</span>'
|
||||
f'<a href="{payments_href}" class="text-sm underline">configure</a>'
|
||||
'</div>'
|
||||
'</div>'
|
||||
)
|
||||
|
||||
|
||||
def _cart_payments_main_panel_html(ctx: dict) -> str:
|
||||
"""Render SumUp payment config form."""
|
||||
from quart import url_for
|
||||
csrf_token = ctx.get("csrf_token")
|
||||
csrf = csrf_token() if callable(csrf_token) else (csrf_token or "")
|
||||
page_config = ctx.get("page_config")
|
||||
sumup_configured = bool(page_config and getattr(page_config, "sumup_api_key", None))
|
||||
merchant_code = (getattr(page_config, "sumup_merchant_code", None) or "") if page_config else ""
|
||||
checkout_prefix = (getattr(page_config, "sumup_checkout_prefix", None) or "") if page_config else ""
|
||||
update_url = url_for("page_admin.update_sumup")
|
||||
|
||||
placeholder = "--------" if sumup_configured else "sup_sk_..."
|
||||
input_cls = "w-full px-3 py-1.5 text-sm border border-stone-300 rounded focus:ring-purple-500 focus:border-purple-500"
|
||||
|
||||
return render("cart-payments-panel",
|
||||
update_url=update_url, csrf=csrf,
|
||||
merchant_code=merchant_code, placeholder=placeholder,
|
||||
input_cls=input_cls, sumup_configured=sumup_configured,
|
||||
checkout_prefix=checkout_prefix)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API: Cart page admin
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_cart_admin_page(ctx: dict, page_post: Any) -> str:
|
||||
"""Full page: cart page admin overview."""
|
||||
content = _cart_admin_main_panel_html(ctx)
|
||||
hdr = root_header_html(ctx)
|
||||
child = _page_cart_header_html(ctx, page_post) + _cart_page_admin_header_html(ctx, page_post)
|
||||
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_admin_oob(ctx: dict, page_post: Any) -> str:
|
||||
"""OOB response: cart page admin overview."""
|
||||
content = _cart_admin_main_panel_html(ctx)
|
||||
oobs = (
|
||||
_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)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API: Cart payments admin
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_cart_payments_page(ctx: dict, page_post: Any) -> str:
|
||||
"""Full page: payments config."""
|
||||
content = _cart_payments_main_panel_html(ctx)
|
||||
hdr = root_header_html(ctx)
|
||||
admin_hdr = _cart_page_admin_header_html(ctx, page_post)
|
||||
payments_hdr = _cart_payments_header_html(ctx)
|
||||
child = _page_cart_header_html(ctx, page_post) + admin_hdr + payments_hdr
|
||||
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:
|
||||
"""OOB response: payments config."""
|
||||
content = _cart_payments_main_panel_html(ctx)
|
||||
admin_hdr = _cart_page_admin_header_html(ctx, page_post)
|
||||
payments_hdr = _cart_payments_header_html(ctx)
|
||||
oobs = (
|
||||
_cart_payments_header_html(ctx, oob=True)
|
||||
+ render("cart-header-child-oob",
|
||||
inner_html=_page_cart_header_html(ctx, page_post)
|
||||
+ admin_hdr + payments_hdr)
|
||||
+ _cart_header_html(ctx, oob=True)
|
||||
+ root_header_html(ctx, oob=True)
|
||||
)
|
||||
return oob_page(ctx, oobs_html=oobs, content_html=content)
|
||||
|
||||
|
||||
def render_cart_payments_panel(ctx: dict) -> str:
|
||||
"""Render the payments config panel for PUT response."""
|
||||
return _cart_payments_main_panel_html(ctx)
|
||||
|
||||
Reference in New Issue
Block a user