Systemet til håndtering af Fælles Vinindkøb
Find a file
carsten acaa2383e9 Add admin CRUD for purchase rounds and wine offerings, with round copy
Full CRUD on PurchaseRound and WineOffering, org-scoped via two new
join-based dependencies.py helpers (get_round_in_organization,
get_wine_offering_in_organization) mirroring task 5's pattern. New
rounds always start as draft regardless of what the client posts,
avoiding a confusing creation-time constraint error.

POST /purchase-rounds/{id}/copy implements "kopiér fra forrige runde":
duplicates every round field (dates, texts) and every wine offering
(incl. category) into a fresh draft, leaving the source untouched.

PurchaseRound DELETE gets a three-tier policy based on status: draft
deletable by any admin, open never deletable, closed only by an
elevated superadmin. This is runtime-conditional on the loaded row, so
the elevation check was extracted out of get_current_active_superuser
into a standalone require_elevated_superuser(user, token) helper that
both the dependency and this handler call directly. WineOffering
delete has no such tier — an offering with real order lines is already
blocked by the existing RESTRICT FK, caught here as a 409.

Also seeds the 8 wine categories (empty table blocked any offering
creation) via a plain Alembic data migration, idempotent and
unconditional (no secret involved, unlike the task-4 superuser seed).

Verified end-to-end: dates-required 409, open round successfully
patched with dates, wine offerings created, round copied (new draft,
duplicated offerings with new ids/same category), open-round delete
403, closed-round delete 403 then 204 after /auth/elevate, wine
offering delete 204, draft round delete 204 (cascades its remaining
offering). DB left clean, participant count unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-28 18:56:38 +02:00
app Add admin CRUD for purchase rounds and wine offerings, with round copy 2026-09-28 18:56:38 +02:00
migrations Add admin CRUD for purchase rounds and wine offerings, with round copy 2026-09-28 18:56:38 +02:00
scripts Add one-off participant import script for legacy MongoDB data 2026-09-27 19:16:26 +02:00
.env.example Add sudo-style elevation for superadmin actions 2026-09-28 13:19:35 +02:00
.gitignore Add one-off participant import script for legacy MongoDB data 2026-09-27 19:16:26 +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 simple JWT login for User 2026-09-27 22:23:25 +02:00
README.md Scaffold FastAPI + SQLModel + Alembic project, Postgres-backed 2026-09-27 15:57:44 +02:00
uv.lock Add simple JWT login for User 2026-09-27 22:23:25 +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.