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
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:
@@ -13,7 +13,7 @@ from .services.post_data import post_data
|
||||
from shared.infrastructure.data_client import fetch_data
|
||||
from shared.infrastructure.actions import call_action
|
||||
from shared.contracts.dtos import CartSummaryDTO, dto_from_dict
|
||||
from shared.infrastructure.fragments import fetch_fragment, fetch_fragments
|
||||
from shared.infrastructure.fragments import fetch_fragment
|
||||
|
||||
from shared.browser.app.redis_cacher import cache_page, clear_cache
|
||||
|
||||
@@ -69,22 +69,12 @@ def register():
|
||||
db_post_id = (g.post_data.get("post") or {}).get("id")
|
||||
post_slug = (g.post_data.get("post") or {}).get("slug", "")
|
||||
|
||||
# Fetch container nav fragments from events + market
|
||||
paginate_url = url_for(
|
||||
'blog.post.widget_paginate',
|
||||
slug=post_slug, widget_domain='calendar',
|
||||
)
|
||||
nav_params = {
|
||||
# Fetch container nav from relations service
|
||||
container_nav_html = await fetch_fragment("relations", "container-nav", params={
|
||||
"container_type": "page",
|
||||
"container_id": str(db_post_id),
|
||||
"post_slug": post_slug,
|
||||
"paginate_url": paginate_url,
|
||||
}
|
||||
events_nav_html, market_nav_html = await fetch_fragments([
|
||||
("events", "container-nav", nav_params),
|
||||
("market", "container-nav", nav_params),
|
||||
])
|
||||
container_nav_html = events_nav_html + market_nav_html
|
||||
})
|
||||
|
||||
ctx = {
|
||||
**p_data,
|
||||
|
||||
@@ -7,7 +7,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from shared.contracts.dtos import MarketPlaceDTO
|
||||
from shared.infrastructure.actions import call_action, ActionError
|
||||
from shared.infrastructure.data_client import fetch_data
|
||||
from shared.services.registry import services
|
||||
|
||||
|
||||
@@ -41,11 +40,11 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
|
||||
if not post.is_page:
|
||||
raise MarketError("Markets can only be created on pages, not posts.")
|
||||
|
||||
raw_pc = await fetch_data("blog", "page-config",
|
||||
params={"container_type": "page", "container_id": post_id},
|
||||
required=False)
|
||||
if raw_pc is None or not (raw_pc.get("features") or {}).get("market"):
|
||||
raise MarketError("Market feature is not enabled for this page. Enable it in page settings first.")
|
||||
check = await call_action("relations", "can-relate", payload={
|
||||
"relation_type": "page->market", "from_id": post_id,
|
||||
})
|
||||
if not check.get("allowed"):
|
||||
raise MarketError(check.get("reason", "Cannot create market for this page."))
|
||||
|
||||
try:
|
||||
result = await call_action("market", "create-marketplace", payload={
|
||||
|
||||
Reference in New Issue
Block a user