Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 21s
Splits the monolithic cart blueprint into three: cart_overview (GET /), page_cart (/<page_slug>/), and cart_global (webhook, return, add). - New page_cart.py service: get_cart_for_page(), get_calendar_entries_for_page(), get_cart_grouped_by_page() - clear_cart_for_order() and create_order_from_cart() accept page_post_id for scoping - Cart app hydrates page_slug via url_value_preprocessor/url_defaults/hydrate_page - Context processor provides page-scoped cart data when g.page_post exists - Internal API /internal/cart/summary accepts ?page_slug= for page-scoped counts - Overview template shows page cards with item counts and totals - Page cart template reuses show_cart() macro with page-specific header Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
702 B
Python
26 lines
702 B
Python
from sqlalchemy import select
|
|
from sqlalchemy.orm import selectinload
|
|
|
|
from models.market import CartItem
|
|
from .identity import current_cart_identity
|
|
|
|
async def get_cart(session):
|
|
ident = current_cart_identity()
|
|
|
|
filters = [CartItem.deleted_at.is_(None)]
|
|
if ident["user_id"] is not None:
|
|
filters.append(CartItem.user_id == ident["user_id"])
|
|
else:
|
|
filters.append(CartItem.session_id == ident["session_id"])
|
|
|
|
result = await session.execute(
|
|
select(CartItem)
|
|
.where(*filters)
|
|
.order_by(CartItem.created_at.desc())
|
|
.options(
|
|
selectinload(CartItem.product),
|
|
selectinload(CartItem.market_place),
|
|
)
|
|
)
|
|
return result.scalars().all()
|