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:
@@ -171,6 +171,32 @@ def register() -> Blueprint:
|
||||
|
||||
_handlers["page-configs-batch"] = _page_configs_batch
|
||||
|
||||
# --- get-children ---
|
||||
async def _get_children():
|
||||
"""Return ContainerRelation children for a parent."""
|
||||
from shared.services.relationships import get_children
|
||||
|
||||
parent_type = request.args.get("parent_type", "")
|
||||
parent_id = request.args.get("parent_id", type=int)
|
||||
child_type = request.args.get("child_type")
|
||||
if not parent_type or parent_id is None:
|
||||
return []
|
||||
rels = await get_children(g.s, parent_type, parent_id, child_type)
|
||||
return [
|
||||
{
|
||||
"id": r.id,
|
||||
"parent_type": r.parent_type,
|
||||
"parent_id": r.parent_id,
|
||||
"child_type": r.child_type,
|
||||
"child_id": r.child_id,
|
||||
"sort_order": r.sort_order,
|
||||
"label": r.label,
|
||||
}
|
||||
for r in rels
|
||||
]
|
||||
|
||||
_handlers["get-children"] = _get_children
|
||||
|
||||
return bp
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user