Add attach/detach glue calls to menu items, markets, and page config CRUD
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 45s

Wire up ContainerRelation tracking via attach_child/detach_child in:
- menu_items: create, update (re-link on post change), delete
- markets: create (including revive), soft_delete
- page config: creation in update_features and update_sumup routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-14 09:52:12 +00:00
parent 70ef1910c1
commit 75a5d520e8
3 changed files with 16 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, func
from glue.models.menu_node import MenuNode
from models.ghost_content import Post
from glue.services.relationships import attach_child, detach_child
class MenuItemError(ValueError):
@@ -79,6 +80,7 @@ async def create_menu_item(
)
session.add(menu_node)
await session.flush()
await attach_child(session, "page", post_id, "menu_node", menu_node.id)
return menu_node
@@ -117,6 +119,7 @@ async def update_menu_item(
if existing:
raise MenuItemError("Menu item for this page already exists.")
old_post_id = menu_node.container_id
menu_node.container_id = post_id
menu_node.label = post.title
menu_node.slug = post.slug
@@ -127,6 +130,10 @@ async def update_menu_item(
await session.flush()
if post_id is not None and post_id != old_post_id:
await detach_child(session, "page", old_post_id, "menu_node", menu_node.id)
await attach_child(session, "page", post_id, "menu_node", menu_node.id)
return menu_node
@@ -138,6 +145,7 @@ async def delete_menu_item(session: AsyncSession, item_id: int) -> bool:
menu_node.deleted_at = func.now()
await session.flush()
await detach_child(session, "page", menu_node.container_id, "menu_node", menu_node.id)
return True