Initial commit: Pole Dance Championships App
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>
This commit is contained in:
62
backend/app/crud/crud_participant.py
Normal file
62
backend/app/crud/crud_participant.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.participant_list import ParticipantList
|
||||
|
||||
|
||||
def _uuid(v: str | uuid.UUID) -> uuid.UUID:
|
||||
return v if isinstance(v, uuid.UUID) else uuid.UUID(str(v))
|
||||
|
||||
|
||||
async def get_by_championship(
|
||||
db: AsyncSession, championship_id: str | uuid.UUID
|
||||
) -> ParticipantList | None:
|
||||
result = await db.execute(
|
||||
select(ParticipantList).where(
|
||||
ParticipantList.championship_id == _uuid(championship_id)
|
||||
)
|
||||
)
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
|
||||
async def upsert(
|
||||
db: AsyncSession,
|
||||
championship_id: uuid.UUID,
|
||||
published_by: uuid.UUID,
|
||||
notes: str | None,
|
||||
) -> ParticipantList:
|
||||
existing = await get_by_championship(db, championship_id)
|
||||
if existing:
|
||||
existing.notes = notes
|
||||
existing.published_by = published_by
|
||||
await db.commit()
|
||||
await db.refresh(existing)
|
||||
return existing
|
||||
pl = ParticipantList(
|
||||
championship_id=championship_id,
|
||||
published_by=published_by,
|
||||
notes=notes,
|
||||
)
|
||||
db.add(pl)
|
||||
await db.commit()
|
||||
await db.refresh(pl)
|
||||
return pl
|
||||
|
||||
|
||||
async def publish(db: AsyncSession, pl: ParticipantList) -> ParticipantList:
|
||||
pl.is_published = True
|
||||
pl.published_at = datetime.now(timezone.utc)
|
||||
await db.commit()
|
||||
await db.refresh(pl)
|
||||
return pl
|
||||
|
||||
|
||||
async def unpublish(db: AsyncSession, pl: ParticipantList) -> ParticipantList:
|
||||
pl.is_published = False
|
||||
pl.published_at = None
|
||||
await db.commit()
|
||||
await db.refresh(pl)
|
||||
return pl
|
||||
Reference in New Issue
Block a user