95 lines
2.7 KiB
Python
95 lines
2.7 KiB
Python
|
|
"""Pydantic schemas for Crew and CrewAvailability."""
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class CrewAvailabilityResponse(BaseModel):
|
||
|
|
"""Public crew availability representation."""
|
||
|
|
id: str
|
||
|
|
crew_id: str
|
||
|
|
start_date: str
|
||
|
|
end_date: str
|
||
|
|
status: str
|
||
|
|
notes: str | None = None
|
||
|
|
created_at: str
|
||
|
|
updated_at: str
|
||
|
|
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
|
||
|
|
class CrewCreateRequest(BaseModel):
|
||
|
|
"""Request body for creating a new crew member."""
|
||
|
|
first_name: str = Field(..., max_length=100)
|
||
|
|
last_name: str = Field(..., max_length=100)
|
||
|
|
email: str | None = Field(None, max_length=255)
|
||
|
|
phone: str | None = Field(None, max_length=50)
|
||
|
|
role_title: str | None = Field(None, max_length=100)
|
||
|
|
hourly_rate: float | None = None
|
||
|
|
is_active: bool = True
|
||
|
|
notes: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class CrewUpdateRequest(BaseModel):
|
||
|
|
"""Request body for updating a crew member."""
|
||
|
|
first_name: str | None = Field(None, max_length=100)
|
||
|
|
last_name: str | None = Field(None, max_length=100)
|
||
|
|
email: str | None = Field(None, max_length=255)
|
||
|
|
phone: str | None = Field(None, max_length=50)
|
||
|
|
role_title: str | None = Field(None, max_length=100)
|
||
|
|
hourly_rate: float | None = None
|
||
|
|
is_active: bool | None = None
|
||
|
|
notes: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class CrewResponse(BaseModel):
|
||
|
|
"""Public crew member representation."""
|
||
|
|
id: str
|
||
|
|
account_id: str
|
||
|
|
first_name: str
|
||
|
|
last_name: str
|
||
|
|
email: str | None = None
|
||
|
|
phone: str | None = None
|
||
|
|
role_title: str | None = None
|
||
|
|
hourly_rate: float | None = None
|
||
|
|
is_active: bool
|
||
|
|
notes: str | None = None
|
||
|
|
created_at: str
|
||
|
|
updated_at: str
|
||
|
|
availabilities: list[CrewAvailabilityResponse] = []
|
||
|
|
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
|
||
|
|
class CrewListResponse(BaseModel):
|
||
|
|
"""Paginated list of crew members."""
|
||
|
|
items: list[CrewResponse]
|
||
|
|
total: int
|
||
|
|
page: int
|
||
|
|
size: int
|
||
|
|
|
||
|
|
|
||
|
|
class CrewAvailabilityCreateRequest(BaseModel):
|
||
|
|
"""Request body for creating crew availability."""
|
||
|
|
crew_id: str
|
||
|
|
start_date: str = Field(..., description="ISO datetime with timezone")
|
||
|
|
end_date: str = Field(..., description="ISO datetime with timezone")
|
||
|
|
status: str = Field("available", max_length=20)
|
||
|
|
notes: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class CrewAvailabilityUpdateRequest(BaseModel):
|
||
|
|
"""Request body for updating crew availability."""
|
||
|
|
start_date: str | None = None
|
||
|
|
end_date: str | None = None
|
||
|
|
status: str | None = Field(None, max_length=20)
|
||
|
|
notes: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class CrewAvailabilityListResponse(BaseModel):
|
||
|
|
"""Paginated list of crew availabilities."""
|
||
|
|
items: list[CrewAvailabilityResponse]
|
||
|
|
total: int
|
||
|
|
page: int
|
||
|
|
size: int
|