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>
87 lines
2.3 KiB
Python
87 lines
2.3 KiB
Python
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.models.registration import Registration
|
|
|
|
|
|
def _uuid(v: str | uuid.UUID) -> uuid.UUID:
|
|
return v if isinstance(v, uuid.UUID) else uuid.UUID(str(v))
|
|
|
|
|
|
async def get(db: AsyncSession, registration_id: str | uuid.UUID) -> Registration | None:
|
|
result = await db.execute(
|
|
select(Registration).where(Registration.id == _uuid(registration_id))
|
|
)
|
|
return result.scalar_one_or_none()
|
|
|
|
|
|
async def get_by_champ_and_user(
|
|
db: AsyncSession, championship_id: str | uuid.UUID, user_id: str | uuid.UUID
|
|
) -> Registration | None:
|
|
result = await db.execute(
|
|
select(Registration).where(
|
|
Registration.championship_id == _uuid(championship_id),
|
|
Registration.user_id == _uuid(user_id),
|
|
)
|
|
)
|
|
return result.scalar_one_or_none()
|
|
|
|
|
|
async def list_by_user(db: AsyncSession, user_id: str | uuid.UUID) -> list[Registration]:
|
|
result = await db.execute(
|
|
select(Registration)
|
|
.where(Registration.user_id == _uuid(user_id))
|
|
.order_by(Registration.submitted_at.desc())
|
|
)
|
|
return list(result.scalars().all())
|
|
|
|
|
|
async def list_by_championship(
|
|
db: AsyncSession, championship_id: str | uuid.UUID
|
|
) -> list[Registration]:
|
|
result = await db.execute(
|
|
select(Registration)
|
|
.where(Registration.championship_id == _uuid(championship_id))
|
|
.order_by(Registration.submitted_at.asc())
|
|
)
|
|
return list(result.scalars().all())
|
|
|
|
|
|
async def create(
|
|
db: AsyncSession,
|
|
championship_id: uuid.UUID,
|
|
user_id: uuid.UUID,
|
|
category: str | None,
|
|
level: str | None,
|
|
notes: str | None,
|
|
) -> Registration:
|
|
reg = Registration(
|
|
championship_id=championship_id,
|
|
user_id=user_id,
|
|
category=category,
|
|
level=level,
|
|
notes=notes,
|
|
)
|
|
db.add(reg)
|
|
await db.commit()
|
|
await db.refresh(reg)
|
|
return reg
|
|
|
|
|
|
async def update_status(
|
|
db: AsyncSession, reg: Registration, status: str
|
|
) -> Registration:
|
|
reg.status = status
|
|
reg.decided_at = datetime.now(timezone.utc)
|
|
await db.commit()
|
|
await db.refresh(reg)
|
|
return reg
|
|
|
|
|
|
async def delete(db: AsyncSession, reg: Registration) -> None:
|
|
await db.delete(reg)
|
|
await db.commit()
|