Systemet til håndtering af Fælles Vinindkøb
Find a file
carsten 34ed5c28d7 Add Postal sending, "annoncér runde" action, and MailLog (task 7b)
POST /purchase-rounds/{id}/announce renders the route's round_announced
MailTemplate with simple {{variable}} substitution (app/services/
mail_rendering.py) for every active participant on the route, sends
via Postal's real HTTP API (app/services/postal.py — request/response
shapes verified directly against docs.postalserver.io, not guessed),
and records one MailLog row per attempt (sent/failed, Postal's
message id + token for the future webhook in 7c, denormalized
rendered_subject so the log reflects what was actually sent even if
the template changes later). A failed send for one participant doesn't
abort the rest — each attempt is isolated and committed individually.

Route gained sender_name/sender_email in 7a; both are now populated
for the real route from the historical emails ("Finn Gram - Fælles
Vinindkøb <finn@vinindkoeb.dk>") directly in the DB, since there's no
Route CRUD API yet.

Verified end-to-end against the real Postal instance: a real test
email was sent and received via an isolated throwaway Organization/
Route/Participant/PurchaseRound/MailTemplate sandbox (never the real
route's 308 participants), MailLog captured the correct Postal message
id/token, and a temporarily-invalid API key produced a clean
sent:0/failed:1 result with Postal's actual error message stored,
not a 500. All test data removed afterward; real route/participant
data confirmed untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-28 20:16:04 +02:00
app Add Postal sending, "annoncér runde" action, and MailLog (task 7b) 2026-09-28 20:16:04 +02:00
migrations Add Postal sending, "annoncér runde" action, and MailLog (task 7b) 2026-09-28 20:16:04 +02:00
scripts Add one-off participant import script for legacy MongoDB data 2026-09-27 19:16:26 +02:00
.env.example Add Postal sending, "annoncér runde" action, and MailLog (task 7b) 2026-09-28 20:16:04 +02:00
.gitignore Add mail template CRUD (task 7a), per-route and per-event-type 2026-09-28 19:43:47 +02:00
.python-version Scaffold FastAPI + SQLModel + Alembic project, Postgres-backed 2026-09-27 15:57:44 +02:00
alembic.ini Scaffold FastAPI + SQLModel + Alembic project, Postgres-backed 2026-09-27 15:57:44 +02:00
CLAUDE.md Scaffold FastAPI + SQLModel + Alembic project, Postgres-backed 2026-09-27 15:57:44 +02:00
pyproject.toml Add Postal sending, "annoncér runde" action, and MailLog (task 7b) 2026-09-28 20:16:04 +02:00
README.md Scaffold FastAPI + SQLModel + Alembic project, Postgres-backed 2026-09-27 15:57:44 +02:00
uv.lock Add Postal sending, "annoncér runde" action, and MailLog (task 7b) 2026-09-28 20:16:04 +02:00

Vinindkøb v2

Admin-backend til fælles vinindkøb (FastAPI + SQLModel + PostgreSQL + Alembic). Se CLAUDE.md for projektplan og datamodel.

Kom i gang

uv sync
cp .env.example .env   # udfyld DATABASE_URL med din egen Postgres-instans
uv run alembic upgrade head
uv run fastapi dev app/main.py

GET /health bekræfter at appen kan nå databasen.