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

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:
2026-02-28 09:24:52 +00:00
parent 53c4a0a1e0
commit d2f1da4944
9 changed files with 65 additions and 70 deletions

View File

@@ -71,9 +71,9 @@ async def soft_delete(sess: AsyncSession, post_slug: str, calendar_slug: str) ->
cal.deleted_at = utcnow()
await sess.flush()
await call_action("relations", "detach-child", payload={
"parent_type": "page", "parent_id": cal.container_id,
"child_type": "calendar", "child_id": cal.id,
await call_action("relations", "unrelate", payload={
"relation_type": "page->calendar",
"from_id": cal.container_id, "to_id": cal.id,
})
return True
@@ -108,9 +108,11 @@ async def create_calendar(sess: AsyncSession, post_id: int, name: str) -> Calend
if existing.deleted_at is not None:
existing.deleted_at = None # revive
await sess.flush()
await call_action("relations", "attach-child", payload={
"parent_type": "page", "parent_id": post_id,
"child_type": "calendar", "child_id": existing.id,
await call_action("relations", "relate", payload={
"relation_type": "page->calendar",
"from_id": post_id, "to_id": existing.id,
"label": existing.name,
"metadata": {"slug": existing.slug},
})
return existing
raise CalendarError(f'Calendar with slug "{slug}" already exists for post {post_id}.')
@@ -118,9 +120,11 @@ async def create_calendar(sess: AsyncSession, post_id: int, name: str) -> Calend
cal = Calendar(container_type="page", container_id=post_id, name=name, slug=slug)
sess.add(cal)
await sess.flush()
await call_action("relations", "attach-child", payload={
"parent_type": "page", "parent_id": post_id,
"child_type": "calendar", "child_id": cal.id,
await call_action("relations", "relate", payload={
"relation_type": "page->calendar",
"from_id": post_id, "to_id": cal.id,
"label": cal.name,
"metadata": {"slug": cal.slug},
})
return cal