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>
46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Index, String, Text, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
def _now() -> datetime:
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
class Registration(Base):
|
|
__tablename__ = "registrations"
|
|
__table_args__ = (
|
|
UniqueConstraint("championship_id", "user_id", name="uq_registration_champ_user"),
|
|
Index("idx_registrations_championship_id", "championship_id"),
|
|
Index("idx_registrations_user_id", "user_id"),
|
|
)
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
|
|
championship_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("championships.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("users.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
category: Mapped[str | None] = mapped_column(String(255))
|
|
level: Mapped[str | None] = mapped_column(String(255))
|
|
notes: Mapped[str | None] = mapped_column(Text)
|
|
status: Mapped[str] = mapped_column(String(20), nullable=False, default="submitted")
|
|
# 'submitted' | 'accepted' | 'rejected' | 'waitlisted'
|
|
submitted_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now)
|
|
decided_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), default=_now, onupdate=_now
|
|
)
|
|
|
|
championship: Mapped["Championship"] = relationship(back_populates="registrations")
|
|
user: Mapped["User"] = relationship(back_populates="registrations")
|
|
notification_logs: Mapped[list["NotificationLog"]] = relationship(
|
|
back_populates="registration"
|
|
)
|