Add attach/detach glue calls to calendar and market CRUD
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 48s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 48s
Wire up ContainerRelation tracking via attach_child/detach_child in: - calendars: create (including revive), soft_delete - markets: create (including revive), soft_delete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from market.models.market_place import MarketPlace
|
||||
from blog.models.ghost_content import Post
|
||||
from shared.browser.app.utils import utcnow
|
||||
from glue.services.relationships import attach_child, detach_child
|
||||
|
||||
|
||||
class MarketError(ValueError):
|
||||
@@ -55,12 +56,14 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
|
||||
existing.deleted_at = None
|
||||
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
|
||||
|
||||
|
||||
@@ -83,4 +86,5 @@ async def soft_delete(sess: AsyncSession, post_slug: str, market_slug: str) -> b
|
||||
|
||||
market.deleted_at = utcnow()
|
||||
await sess.flush()
|
||||
await detach_child(sess, "page", market.container_id, "market", market.id)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user