Add glue layer: replace /internal/menu-items API with direct DB query
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 41s

- Context processor: get_navigation_tree() replaces api_get("coop", "/internal/menu-items")
- Add glue submodule

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-11 23:37:50 +00:00
parent 14838ebbaa
commit 9cf8ff1114
3 changed files with 7 additions and 5 deletions

3
.gitmodules vendored
View File

@@ -2,3 +2,6 @@
path = shared
url = https://git.rose-ash.com/coop/shared.git
branch = decoupling
[submodule "glue"]
path = glue
url = /root/rose-ash/glue

8
app.py
View File

@@ -40,13 +40,13 @@ async def cart_context() -> dict:
- cart / calendar_cart_entries / total / calendar_total: direct DB
(cart app owns this data)
- cart_count: derived from cart + calendar entries (for _mini.html)
- menu_items: fetched from coop internal API
- menu_items: direct DB query via glue layer
When g.page_post exists, cart and calendar_cart_entries are page-scoped.
Global cart_count / cart_total stay global for cart-mini.
"""
from shared.infrastructure.context import base_context
from shared.infrastructure.internal_api import get as api_get, dictobj
from glue.services.navigation import get_navigation_tree
ctx = await base_context()
@@ -75,9 +75,7 @@ async def cart_context() -> dict:
ctx["total"] = total
ctx["calendar_total"] = calendar_total
# Menu items from coop API (wrapped for attribute access in templates)
menu_data = await api_get("coop", "/internal/menu-items")
ctx["menu_items"] = dictobj(menu_data) if menu_data else []
ctx["menu_items"] = await get_navigation_tree(g.s)
return ctx

1
glue Submodule

Submodule glue added at f57c765cac