POL-127: Add organizations table and championship ownership
- Create organizations table with Alembic migration (3-phase: create table, migrate data, drop old column) - Add org_id FK on championships linking to organizations - Refactor all schemas into one-class-per-file packages (auth, championship, organization, participant, registration, user) - Update CRUD layer with selectinload for organization relationships - Update frontend types and components to use nested organization object - Remove phantom Championship fields (subtitle, venue, accent_color) from frontend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
backend/app/schemas/registration/__init__.py
Normal file
13
backend/app/schemas/registration/__init__.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from app.schemas.registration.create import RegistrationCreate
|
||||
from app.schemas.registration.update import RegistrationUpdate
|
||||
from app.schemas.registration.out import RegistrationOut
|
||||
from app.schemas.registration.list_item import RegistrationListItem
|
||||
from app.schemas.registration.with_user import RegistrationWithUser
|
||||
|
||||
__all__ = [
|
||||
"RegistrationCreate",
|
||||
"RegistrationUpdate",
|
||||
"RegistrationOut",
|
||||
"RegistrationListItem",
|
||||
"RegistrationWithUser",
|
||||
]
|
||||
10
backend/app/schemas/registration/create.py
Normal file
10
backend/app/schemas/registration/create.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import uuid
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class RegistrationCreate(BaseModel):
|
||||
championship_id: uuid.UUID
|
||||
category: str | None = None
|
||||
level: str | None = None
|
||||
notes: str | None = None
|
||||
22
backend/app/schemas/registration/list_item.py
Normal file
22
backend/app/schemas/registration/list_item.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import model_validator
|
||||
|
||||
from app.schemas.registration.out import RegistrationOut
|
||||
|
||||
|
||||
class RegistrationListItem(RegistrationOut):
|
||||
championship_title: str | None = None
|
||||
championship_event_date: datetime | None = None
|
||||
championship_location: str | None = None
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def extract_championship(cls, data: Any) -> Any:
|
||||
if hasattr(data, "championship") and data.championship:
|
||||
champ = data.championship
|
||||
data.__dict__["championship_title"] = champ.title
|
||||
data.__dict__["championship_event_date"] = champ.event_date
|
||||
data.__dict__["championship_location"] = champ.location
|
||||
return data
|
||||
19
backend/app/schemas/registration/out.py
Normal file
19
backend/app/schemas/registration/out.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class RegistrationOut(BaseModel):
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
id: uuid.UUID
|
||||
championship_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
category: str | None
|
||||
level: str | None
|
||||
notes: str | None
|
||||
status: str
|
||||
video_url: str | None
|
||||
submitted_at: datetime
|
||||
decided_at: datetime | None
|
||||
9
backend/app/schemas/registration/update.py
Normal file
9
backend/app/schemas/registration/update.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class RegistrationUpdate(BaseModel):
|
||||
status: str | None = None
|
||||
video_url: str | None = None
|
||||
category: str | None = None
|
||||
level: str | None = None
|
||||
notes: str | None = None
|
||||
6
backend/app/schemas/registration/with_user.py
Normal file
6
backend/app/schemas/registration/with_user.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from app.schemas.registration.out import RegistrationOut
|
||||
from app.schemas.user import UserOut
|
||||
|
||||
|
||||
class RegistrationWithUser(RegistrationOut):
|
||||
user: UserOut
|
||||
Reference in New Issue
Block a user