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:
6
backend/app/schemas/user/__init__.py
Normal file
6
backend/app/schemas/user/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from app.schemas.user.register import UserRegister
|
||||
from app.schemas.user.login import UserLogin
|
||||
from app.schemas.user.out import UserOut
|
||||
from app.schemas.user.update import UserUpdate
|
||||
|
||||
__all__ = ["UserRegister", "UserLogin", "UserOut", "UserUpdate"]
|
||||
6
backend/app/schemas/user/login.py
Normal file
6
backend/app/schemas/user/login.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from pydantic import BaseModel, EmailStr
|
||||
|
||||
|
||||
class UserLogin(BaseModel):
|
||||
email: EmailStr
|
||||
password: str
|
||||
21
backend/app/schemas/user/out.py
Normal file
21
backend/app/schemas/user/out.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.organization import OrganizationOut
|
||||
|
||||
|
||||
class UserOut(BaseModel):
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
id: uuid.UUID
|
||||
email: str
|
||||
full_name: str
|
||||
phone: str | None
|
||||
role: str
|
||||
status: str
|
||||
instagram_handle: str | None
|
||||
organization: OrganizationOut | None = None
|
||||
expo_push_token: str | None
|
||||
created_at: datetime
|
||||
22
backend/app/schemas/user/register.py
Normal file
22
backend/app/schemas/user/register.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, EmailStr, field_validator
|
||||
|
||||
|
||||
class UserRegister(BaseModel):
|
||||
email: EmailStr
|
||||
password: str
|
||||
full_name: str
|
||||
phone: str | None = None
|
||||
# Role requested at registration: 'member' or 'organizer'
|
||||
requested_role: Literal["member", "organizer"] = "member"
|
||||
# Organizer-only fields
|
||||
organization_name: str | None = None
|
||||
instagram_handle: str | None = None
|
||||
|
||||
@field_validator("organization_name")
|
||||
@classmethod
|
||||
def org_name_required_for_organizer(cls, v, info):
|
||||
if info.data.get("requested_role") == "organizer" and not v:
|
||||
raise ValueError("Organization name is required for organizer registration")
|
||||
return v
|
||||
10
backend/app/schemas/user/update.py
Normal file
10
backend/app/schemas/user/update.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
full_name: str | None = None
|
||||
phone: str | None = None
|
||||
instagram_handle: str | None = None
|
||||
expo_push_token: str | None = None
|
||||
# Org fields — routed to Organization table in CRUD
|
||||
organization_name: str | None = None
|
||||
Reference in New Issue
Block a user