feat: initialize events app with calendars, slots, tickets, and internal API
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Extract events/calendar functionality into standalone microservice: - app.py and events_api.py from apps/events/ - Calendar blueprints (calendars, calendar, calendar_entries, calendar_entry, day, slots, slot, ticket_types, ticket_type) - Templates for all calendar/event views including admin - Dockerfile (APP_MODULE=app:app, IMAGE=events) - entrypoint.sh (no Alembic - migrations managed by blog app) - Gitea CI workflow for build and deploy Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
54
app.py
Normal file
54
app.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from quart import g
|
||||
|
||||
from shared.factory import create_base_app
|
||||
|
||||
from suma_browser.app.bp import register_calendars
|
||||
|
||||
|
||||
async def events_context() -> dict:
|
||||
"""
|
||||
Events app context processor.
|
||||
|
||||
- menu_items: fetched from coop internal API
|
||||
- cart_count/cart_total: fetched from cart internal API
|
||||
"""
|
||||
from shared.context import base_context
|
||||
from shared.internal_api import get as api_get, dictobj
|
||||
|
||||
ctx = await base_context()
|
||||
|
||||
# Menu items from coop API (wrapped for attribute access in templates)
|
||||
menu_data = await api_get("coop", "/internal/menu-items")
|
||||
ctx["menu_items"] = dictobj(menu_data) if menu_data else []
|
||||
|
||||
# Cart data from cart API
|
||||
cart_data = await api_get("cart", "/internal/cart/summary", forward_session=True)
|
||||
if cart_data:
|
||||
ctx["cart_count"] = cart_data.get("count", 0)
|
||||
ctx["cart_total"] = cart_data.get("total", 0)
|
||||
else:
|
||||
ctx["cart_count"] = 0
|
||||
ctx["cart_total"] = 0
|
||||
|
||||
return ctx
|
||||
|
||||
|
||||
def create_app() -> "Quart":
|
||||
app = create_base_app("events", context_fn=events_context)
|
||||
|
||||
# Calendars blueprint at root — standalone mode (no post nesting)
|
||||
app.register_blueprint(
|
||||
register_calendars(),
|
||||
url_prefix="/calendars",
|
||||
)
|
||||
|
||||
# Internal API (server-to-server, CSRF-exempt)
|
||||
from .events_api import register as register_events_api
|
||||
app.register_blueprint(register_events_api())
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user