vinindkoeb/app/main.py
carsten ded23efc6a Add admin CRUD for participants (incl. active/inactive)
Full CRUD on Participant scoped to the caller's organization via new
get_route_in_organization/get_participant_in_organization helpers in
app/dependencies.py (shared cross-cutting spot, reused by task 6).
PATCH is_active is the primary deactivation path — replaces the old
spreadsheet-era "empty order" trick and preserves order history for
participants who leave and later return. DELETE is a separate,
superadmin-gated hard-delete for GDPR erasure requests, which cascades
to the participant's orders.

Adds UNIQUE(route_id, email) at the DB level (existing 308 participants
already conform, per task 3's dedup) plus email normalization on
create/update, so case-variant duplicates can't reappear via the API.
Every write path relies on catching the constraint's IntegrityError for
a clean 409 rather than a racy pre-check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-28 13:05:08 +02:00

15 lines
391 B
Python

from fastapi import FastAPI
from sqlalchemy import text
from app.db import SessionDep
from app.routers import auth, participants
app = FastAPI(title="Vinindkøb Admin API")
app.include_router(auth.router)
app.include_router(participants.router)
@app.get("/health")
def health(session: SessionDep) -> dict:
session.exec(text("SELECT 1"))
return {"status": "ok", "database": "ok"}