Full-stack mobile app for pole dance championship management. Backend: FastAPI + SQLAlchemy 2 (async) + SQLite (dev) / PostgreSQL (prod) - JWT auth with refresh token rotation - Championship CRUD with Instagram Graph API sync (APScheduler) - Registration flow with status management - Participant list publish with Expo push notifications - Alembic migrations, pytest test suite Mobile: React Native + Expo (TypeScript) - Auth gate: pending approval screen for new members - Championships list & detail screens - Registration form with status tracking - React Query + Zustand + React Navigation v6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
import uuid
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.crud import crud_championship, crud_participant
|
|
from app.database import get_db
|
|
from app.dependencies import get_approved_user, get_organizer
|
|
from app.models.user import User
|
|
from app.schemas.participant_list import ParticipantListOut, ParticipantListUpsert
|
|
from app.services import participant_service
|
|
|
|
router = APIRouter(prefix="/championships", tags=["participant-lists"])
|
|
|
|
|
|
@router.get("/{championship_id}/participant-list", response_model=ParticipantListOut)
|
|
async def get_participant_list(
|
|
championship_id: str,
|
|
_user: User = Depends(get_approved_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
pl = await crud_participant.get_by_championship(db, championship_id)
|
|
if not pl or not pl.is_published:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
detail="Participant list not published yet",
|
|
)
|
|
return pl
|
|
|
|
|
|
@router.put("/{championship_id}/participant-list", response_model=ParticipantListOut)
|
|
async def upsert_participant_list(
|
|
championship_id: str,
|
|
body: ParticipantListUpsert,
|
|
organizer: User = Depends(get_organizer),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
champ = await crud_championship.get(db, championship_id)
|
|
if not champ:
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
|
return await crud_participant.upsert(
|
|
db,
|
|
championship_id=uuid.UUID(championship_id),
|
|
published_by=organizer.id,
|
|
notes=body.notes,
|
|
)
|
|
|
|
|
|
@router.post("/{championship_id}/participant-list/publish", response_model=ParticipantListOut)
|
|
async def publish_participant_list(
|
|
championship_id: str,
|
|
organizer: User = Depends(get_organizer),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
champ = await crud_championship.get(db, championship_id)
|
|
if not champ:
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
|
try:
|
|
return await participant_service.publish_participant_list(
|
|
db, uuid.UUID(championship_id), organizer
|
|
)
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e))
|
|
|
|
|
|
@router.post("/{championship_id}/participant-list/unpublish", response_model=ParticipantListOut)
|
|
async def unpublish_participant_list(
|
|
championship_id: str,
|
|
_organizer: User = Depends(get_organizer),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
pl = await crud_participant.get_by_championship(db, championship_id)
|
|
if not pl:
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
|
return await crud_participant.unpublish(db, pl)
|