Move container_relations to cart service for cross-service ownership
container_relations is a generic parent/child graph used by blog (menu_nodes), market (marketplaces), and events (calendars). Move it to cart as shared infrastructure. All services now call cart actions (attach-child/detach-child) instead of querying the table directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -109,4 +109,47 @@ def register() -> Blueprint:
|
||||
|
||||
_handlers["update-page-config"] = _update_page_config
|
||||
|
||||
# --- attach-child ---
|
||||
async def _attach_child():
|
||||
"""Create or revive a ContainerRelation."""
|
||||
from shared.services.relationships import attach_child
|
||||
|
||||
data = await request.get_json(force=True)
|
||||
rel = await attach_child(
|
||||
g.s,
|
||||
parent_type=data["parent_type"],
|
||||
parent_id=data["parent_id"],
|
||||
child_type=data["child_type"],
|
||||
child_id=data["child_id"],
|
||||
label=data.get("label"),
|
||||
sort_order=data.get("sort_order"),
|
||||
)
|
||||
return {
|
||||
"id": rel.id,
|
||||
"parent_type": rel.parent_type,
|
||||
"parent_id": rel.parent_id,
|
||||
"child_type": rel.child_type,
|
||||
"child_id": rel.child_id,
|
||||
"sort_order": rel.sort_order,
|
||||
}
|
||||
|
||||
_handlers["attach-child"] = _attach_child
|
||||
|
||||
# --- detach-child ---
|
||||
async def _detach_child():
|
||||
"""Soft-delete a ContainerRelation."""
|
||||
from shared.services.relationships import detach_child
|
||||
|
||||
data = await request.get_json(force=True)
|
||||
deleted = await detach_child(
|
||||
g.s,
|
||||
parent_type=data["parent_type"],
|
||||
parent_id=data["parent_id"],
|
||||
child_type=data["child_type"],
|
||||
child_id=data["child_id"],
|
||||
)
|
||||
return {"deleted": deleted}
|
||||
|
||||
_handlers["detach-child"] = _detach_child
|
||||
|
||||
return bp
|
||||
|
||||
Reference in New Issue
Block a user