All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m0s
Replace every direct cross-app services.* call with HTTP-based communication: call_action() for writes, fetch_data() for reads. Each app now registers only its own domain service. Infrastructure: - shared/infrastructure/actions.py — POST client for /internal/actions/ - shared/infrastructure/data_client.py — GET client for /internal/data/ - shared/contracts/dtos.py — dto_to_dict/dto_from_dict serialization Action endpoints (writes): - events: 8 handlers (ticket adjust, claim/confirm, toggle, adopt) - market: 2 handlers (create/soft-delete marketplace) - cart: 1 handler (adopt cart for user) Data endpoints (reads): - blog: 4 (post-by-slug/id, posts-by-ids, search-posts) - events: 10 (pending entries/tickets, entries/tickets for page/order, entry-ids, associated-entries, calendars, visible-entries-for-period) - market: 1 (marketplaces-for-container) - cart: 1 (cart-summary) Service registration cleanup: - blog→blog+federation, events→calendar+federation, market→market+federation, cart→cart only, federation→federation only, account→nothing - Stubs reduced to minimal StubFederationService Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84 lines
2.9 KiB
Python
84 lines
2.9 KiB
Python
from __future__ import annotations
|
|
import path_setup # noqa: F401 # adds shared/ to sys.path
|
|
from pathlib import Path
|
|
|
|
from quart import g, request
|
|
from jinja2 import FileSystemLoader, ChoiceLoader
|
|
|
|
from shared.infrastructure.factory import create_base_app
|
|
|
|
from bp import register_account_bp, register_auth_bp, register_fragments
|
|
|
|
|
|
async def account_context() -> dict:
|
|
"""Account app context processor."""
|
|
from shared.infrastructure.context import base_context
|
|
from shared.services.navigation import get_navigation_tree
|
|
from shared.infrastructure.cart_identity import current_cart_identity
|
|
from shared.infrastructure.fragments import fetch_fragments
|
|
from shared.infrastructure.data_client import fetch_data
|
|
from shared.contracts.dtos import CartSummaryDTO, dto_from_dict
|
|
|
|
ctx = await base_context()
|
|
|
|
# Fallback for _nav.html when nav-tree fragment fetch fails
|
|
ctx["menu_items"] = await get_navigation_tree(g.s)
|
|
|
|
# Cart data via internal data endpoint
|
|
ident = current_cart_identity()
|
|
summary_params = {}
|
|
if ident["user_id"] is not None:
|
|
summary_params["user_id"] = ident["user_id"]
|
|
if ident["session_id"] is not None:
|
|
summary_params["session_id"] = ident["session_id"]
|
|
raw = await fetch_data("cart", "cart-summary", params=summary_params, required=False)
|
|
summary = dto_from_dict(CartSummaryDTO, raw) if raw else CartSummaryDTO()
|
|
ctx["cart_count"] = summary.count + summary.calendar_count + summary.ticket_count
|
|
ctx["cart_total"] = float(summary.total + summary.calendar_total + summary.ticket_total)
|
|
|
|
# Pre-fetch cross-app HTML fragments concurrently
|
|
user = getattr(g, "user", None)
|
|
cart_params = {}
|
|
if ident["user_id"] is not None:
|
|
cart_params["user_id"] = ident["user_id"]
|
|
if ident["session_id"] is not None:
|
|
cart_params["session_id"] = ident["session_id"]
|
|
|
|
cart_mini_html, auth_menu_html, nav_tree_html = await fetch_fragments([
|
|
("cart", "cart-mini", cart_params or None),
|
|
("account", "auth-menu", {"email": user.email} if user else None),
|
|
("blog", "nav-tree", {"app_name": "account", "path": request.path}),
|
|
])
|
|
ctx["cart_mini_html"] = cart_mini_html
|
|
ctx["auth_menu_html"] = auth_menu_html
|
|
ctx["nav_tree_html"] = nav_tree_html
|
|
|
|
return ctx
|
|
|
|
|
|
def create_app() -> "Quart":
|
|
from services import register_domain_services
|
|
|
|
app = create_base_app(
|
|
"account",
|
|
context_fn=account_context,
|
|
domain_services_fn=register_domain_services,
|
|
)
|
|
|
|
# App-specific templates override shared templates
|
|
app_templates = str(Path(__file__).resolve().parent / "templates")
|
|
app.jinja_loader = ChoiceLoader([
|
|
FileSystemLoader(app_templates),
|
|
app.jinja_loader,
|
|
])
|
|
|
|
# --- blueprints ---
|
|
app.register_blueprint(register_auth_bp())
|
|
app.register_blueprint(register_account_bp())
|
|
app.register_blueprint(register_fragments())
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|