feat: decouple events from shared_lib, add app-owned models
Phase 1-3 of decoupling: - path_setup.py adds project root to sys.path - Events-owned models in events/models/ (calendars with all related models) - All imports updated: shared.infrastructure, shared.db, shared.browser, etc. - Calendar uses container_type/container_id instead of post_id FK - CalendarEntryPost uses content_type/content_id (generic content refs) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,16 +5,16 @@ from quart import (
|
||||
)
|
||||
from sqlalchemy import select
|
||||
|
||||
from models.market_place import MarketPlace
|
||||
from market.models.market_place import MarketPlace
|
||||
|
||||
from .services.markets import (
|
||||
create_market as svc_create_market,
|
||||
soft_delete as svc_soft_delete,
|
||||
)
|
||||
|
||||
from suma_browser.app.redis_cacher import cache_page, clear_cache
|
||||
from suma_browser.app.authz import require_admin
|
||||
from suma_browser.app.utils.htmx import is_htmx_request
|
||||
from shared.browser.app.redis_cacher import cache_page, clear_cache
|
||||
from shared.browser.app.authz import require_admin
|
||||
from shared.browser.app.utils.htmx import is_htmx_request
|
||||
|
||||
|
||||
def register():
|
||||
|
||||
@@ -6,9 +6,9 @@ import unicodedata
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from models.market_place import MarketPlace
|
||||
from models.ghost_content import Post
|
||||
from suma_browser.app.utils import utcnow
|
||||
from market.models.market_place import MarketPlace
|
||||
from blog.models.ghost_content import Post
|
||||
from shared.browser.app.utils import utcnow
|
||||
|
||||
|
||||
class MarketError(ValueError):
|
||||
@@ -47,7 +47,7 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
|
||||
|
||||
# Look for existing (including soft-deleted)
|
||||
existing = (await sess.execute(
|
||||
select(MarketPlace).where(MarketPlace.post_id == post_id, MarketPlace.slug == slug)
|
||||
select(MarketPlace).where(MarketPlace.container_type == "page", MarketPlace.container_id == post_id, MarketPlace.slug == slug)
|
||||
)).scalar_one_or_none()
|
||||
|
||||
if existing:
|
||||
@@ -58,7 +58,7 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
|
||||
return existing
|
||||
raise MarketError(f'Market with slug "{slug}" already exists for this page.')
|
||||
|
||||
market = MarketPlace(post_id=post_id, name=name, slug=slug)
|
||||
market = MarketPlace(container_type="page", container_id=post_id, name=name, slug=slug)
|
||||
sess.add(market)
|
||||
await sess.flush()
|
||||
return market
|
||||
@@ -68,7 +68,8 @@ async def soft_delete(sess: AsyncSession, post_slug: str, market_slug: str) -> b
|
||||
market = (
|
||||
await sess.execute(
|
||||
select(MarketPlace)
|
||||
.join(Post, MarketPlace.post_id == Post.id)
|
||||
.join(Post, MarketPlace.container_id == Post.id)
|
||||
.where(MarketPlace.container_type == "page")
|
||||
.where(
|
||||
Post.slug == post_slug,
|
||||
MarketPlace.slug == market_slug,
|
||||
|
||||
Reference in New Issue
Block a user