Combines shared, blog, market, cart, events, federation, and account into a single repository. Eliminates submodule sync, sibling model copying at build time, and per-app CI orchestration. Changes: - Remove per-app .git, .gitmodules, .gitea, submodule shared/ dirs - Remove stale sibling model copies from each app - Update all 6 Dockerfiles for monorepo build context (root = .) - Add build directives to docker-compose.yml - Add single .gitea/workflows/ci.yml with change detection - Add .dockerignore for monorepo build context - Create __init__.py for federation and account (cross-app imports)
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from decimal import Decimal
|
|
|
|
from shared.services.registry import services
|
|
from .identity import current_cart_identity
|
|
|
|
|
|
async def get_calendar_cart_entries(session):
|
|
"""
|
|
Return all *pending* calendar entries (as CalendarEntryDTOs) for the
|
|
current cart identity (user or anonymous session).
|
|
"""
|
|
ident = current_cart_identity()
|
|
return await services.calendar.pending_entries(
|
|
session,
|
|
user_id=ident["user_id"],
|
|
session_id=ident["session_id"],
|
|
)
|
|
|
|
|
|
def calendar_total(entries) -> Decimal:
|
|
"""
|
|
Total cost of pending calendar entries.
|
|
"""
|
|
return sum(
|
|
(Decimal(str(e.cost)) if e.cost else Decimal(0))
|
|
for e in entries
|
|
if e.cost is not None
|
|
)
|
|
|
|
|
|
async def get_ticket_cart_entries(session):
|
|
"""Return all reserved tickets (as TicketDTOs) for the current identity."""
|
|
ident = current_cart_identity()
|
|
return await services.calendar.pending_tickets(
|
|
session,
|
|
user_id=ident["user_id"],
|
|
session_id=ident["session_id"],
|
|
)
|
|
|
|
|
|
def ticket_total(tickets) -> Decimal:
|
|
"""Total cost of reserved tickets."""
|
|
return sum((Decimal(str(t.price)) if t.price else Decimal(0) for t in tickets), Decimal(0))
|