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

@@ -82,6 +82,8 @@ def register():
pc = PageConfig(container_type="page", container_id=post_id, features={})
g.s.add(pc)
await g.s.flush()
from glue.services.relationships import attach_child
await attach_child(g.s, "page", post_id, "page_config", pc.id)
# Parse request body
body = await request.get_json()
@@ -144,6 +146,8 @@ def register():
pc = PageConfig(container_type="page", container_id=post_id, features={})
g.s.add(pc)
await g.s.flush()
from glue.services.relationships import attach_child
await attach_child(g.s, "page", post_id, "page_config", pc.id)
form = await request.form
merchant_code = (form.get("merchant_code") or "").strip()

View File

@@ -10,6 +10,7 @@ from market.models.market_place import MarketPlace
from models.ghost_content import Post
from cart.models.page_config import PageConfig
from shared.browser.app.utils import utcnow
from glue.services.relationships import attach_child, detach_child
class MarketError(ValueError):
@@ -58,12 +59,14 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
existing.deleted_at = None # revive
existing.name = name
await sess.flush()
await attach_child(sess, "page", post_id, "market", existing.id)
return existing
raise MarketError(f'Market with slug "{slug}" already exists for this page.')
market = MarketPlace(container_type="page", container_id=post_id, name=name, slug=slug)
sess.add(market)
await sess.flush()
await attach_child(sess, "page", post_id, "market", market.id)
return market
@@ -86,4 +89,5 @@ async def soft_delete_market(sess: AsyncSession, post_slug: str, market_slug: st
market.deleted_at = utcnow()
await sess.flush()
await detach_child(sess, "page", market.container_id, "market", market.id)
return True