Migrate callers from attach-child/detach-child to relate/unrelate API
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m18s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m18s
Switch all cross-service relation calls to the new registry-aware relate/unrelate/can-relate actions, and consolidate per-service container-nav fragment fetches into the generic relations handler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,9 +80,11 @@ async def create_menu_item(
|
||||
)
|
||||
session.add(menu_node)
|
||||
await session.flush()
|
||||
await call_action("relations", "attach-child", payload={
|
||||
"parent_type": "page", "parent_id": post_id,
|
||||
"child_type": "menu_node", "child_id": menu_node.id,
|
||||
await call_action("relations", "relate", payload={
|
||||
"relation_type": "page->menu_node",
|
||||
"from_id": post_id, "to_id": menu_node.id,
|
||||
"label": post.title,
|
||||
"metadata": {"slug": post.slug},
|
||||
})
|
||||
|
||||
return menu_node
|
||||
@@ -134,13 +136,15 @@ async def update_menu_item(
|
||||
await session.flush()
|
||||
|
||||
if post_id is not None and post_id != old_post_id:
|
||||
await call_action("relations", "detach-child", payload={
|
||||
"parent_type": "page", "parent_id": old_post_id,
|
||||
"child_type": "menu_node", "child_id": menu_node.id,
|
||||
await call_action("relations", "unrelate", payload={
|
||||
"relation_type": "page->menu_node",
|
||||
"from_id": old_post_id, "to_id": menu_node.id,
|
||||
})
|
||||
await call_action("relations", "attach-child", payload={
|
||||
"parent_type": "page", "parent_id": post_id,
|
||||
"child_type": "menu_node", "child_id": menu_node.id,
|
||||
await call_action("relations", "relate", payload={
|
||||
"relation_type": "page->menu_node",
|
||||
"from_id": post_id, "to_id": menu_node.id,
|
||||
"label": post.title,
|
||||
"metadata": {"slug": post.slug},
|
||||
})
|
||||
|
||||
return menu_node
|
||||
@@ -154,9 +158,9 @@ async def delete_menu_item(session: AsyncSession, item_id: int) -> bool:
|
||||
|
||||
menu_node.deleted_at = func.now()
|
||||
await session.flush()
|
||||
await call_action("relations", "detach-child", payload={
|
||||
"parent_type": "page", "parent_id": menu_node.container_id,
|
||||
"child_type": "menu_node", "child_id": menu_node.id,
|
||||
await call_action("relations", "unrelate", payload={
|
||||
"relation_type": "page->menu_node",
|
||||
"from_id": menu_node.container_id, "to_id": menu_node.id,
|
||||
})
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user