MailTemplate holds subject + body_html with plain {{variable}}
placeholders (no loops/conditionals — the user edits these directly
and is comfortable generating list-shaped content like the wine
catalog in code instead, per the real "Kvitering" email reviewed in
old-emails/). One template per (route, event_type), matching the
three CLAUDE.md mail-events (round_announced, order_confirmed,
payment_confirmed); UNIQUE(route_id, event_type) enforces that and
IntegrityError is caught as 409, same pattern as prior tasks.
Route gains nullable sender_name/sender_email — the real old emails
show a per-route sender identity (e.g. "Finn Gram <finn@vinindkoeb.dk>"
for this route), so it lives on Route rather than being duplicated
across each of its templates.
This is data + CRUD only. Actual Postal sending, the round-announce
action, and per-participant send logging are task 7b; a Postal
webhook receiver for delivery status is task 7c — both need real
Postal API access, still to be arranged.
old-emails/ (real historical order/participant data) is gitignored,
same treatment as old_participants.json.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
19 lines
627 B
Python
19 lines
627 B
Python
from fastapi import FastAPI
|
|
from sqlalchemy import text
|
|
|
|
from app.db import SessionDep
|
|
from app.routers import auth, mail_templates, participants, purchase_rounds, wine_categories, wine_offerings
|
|
|
|
app = FastAPI(title="Vinindkøb Admin API")
|
|
app.include_router(auth.router)
|
|
app.include_router(participants.router)
|
|
app.include_router(purchase_rounds.router)
|
|
app.include_router(wine_offerings.router)
|
|
app.include_router(wine_categories.router)
|
|
app.include_router(mail_templates.router)
|
|
|
|
|
|
@app.get("/health")
|
|
def health(session: SessionDep) -> dict:
|
|
session.exec(text("SELECT 1"))
|
|
return {"status": "ok", "database": "ok"}
|