Initial commit: Rentman Clone - Phase 0-6 (T001-T023)
Completed: - Phase 0: Project Setup (T001-T003) - Docker Compose, FastAPI skeleton, React SPA - Phase 1: Auth System (T004-T008) - DB models, JWT auth, RBAC middleware, user management - Phase 2: Contacts & Tags (T009-T011) - CRUD API + UI - Phase 3: Equipment Catalog (T012-T014) - Models, API, UI with barcode/QR - Phase 4: Crew Management (T015-T017) - Models, availability, UI - Phase 5: Vehicle Fleet (T018-T020) - Models, assignments, UI - Phase 6: Projects (T021-T023) - Project hierarchy models, CRUD API, list/detail UI
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""Pydantic schemas for authentication endpoints."""
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
|
||||
class RegisterRequest(BaseModel):
|
||||
"""Request body for self-service registration."""
|
||||
account_name: str = Field(..., min_length=2, max_length=255, description="Company/account name")
|
||||
full_name: str = Field(..., min_length=2, max_length=255, description="Admin user's full name")
|
||||
email: EmailStr = Field(..., description="Admin user's email address")
|
||||
password: str = Field(..., min_length=8, max_length=128, description="Password (min 8 characters)")
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
"""Request body for login."""
|
||||
email: EmailStr
|
||||
password: str
|
||||
|
||||
|
||||
class RefreshRequest(BaseModel):
|
||||
"""Request body for token refresh."""
|
||||
refresh_token: str
|
||||
|
||||
|
||||
class UserInfo(BaseModel):
|
||||
"""Basic user info returned with tokens (no password hash)."""
|
||||
id: str
|
||||
email: str
|
||||
full_name: str
|
||||
account_id: str
|
||||
role_id: str | None = None
|
||||
role_name: str | None = None
|
||||
permissions: list[str] = []
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
"""Response with access and refresh tokens, plus user info."""
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
token_type: str = "bearer"
|
||||
user: UserInfo
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
"""Public user representation (no password hash)."""
|
||||
id: str
|
||||
email: str
|
||||
full_name: str
|
||||
is_active: bool
|
||||
role_id: str | None = None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
@@ -0,0 +1,101 @@
|
||||
"""Pydantic schemas for contacts and tags."""
|
||||
|
||||
from pydantic import BaseModel, Field, EmailStr
|
||||
|
||||
|
||||
class TagResponse(BaseModel):
|
||||
"""Public tag representation."""
|
||||
id: str
|
||||
name: str
|
||||
color: str | None = None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ContactCreateRequest(BaseModel):
|
||||
"""Request body for creating a new contact."""
|
||||
type: str = Field(..., pattern="^(company|person)$")
|
||||
company_name: str | None = Field(None, max_length=255)
|
||||
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)
|
||||
mobile: str | None = Field(None, max_length=50)
|
||||
website: str | None = Field(None, max_length=500)
|
||||
billing_street: str | None = Field(None, max_length=255)
|
||||
billing_number: str | None = Field(None, max_length=20)
|
||||
billing_postalcode: str | None = Field(None, max_length=20)
|
||||
billing_city: str | None = Field(None, max_length=100)
|
||||
billing_country: str | None = Field(None, max_length=100)
|
||||
shipping_street: str | None = Field(None, max_length=255)
|
||||
shipping_number: str | None = Field(None, max_length=20)
|
||||
shipping_postalcode: str | None = Field(None, max_length=20)
|
||||
shipping_city: str | None = Field(None, max_length=100)
|
||||
shipping_country: str | None = Field(None, max_length=100)
|
||||
tax_number: str | None = Field(None, max_length=50)
|
||||
note: str | None = None
|
||||
tag_ids: list[str] = []
|
||||
|
||||
|
||||
class ContactUpdateRequest(BaseModel):
|
||||
"""Request body for updating an existing contact."""
|
||||
type: str | None = Field(None, pattern="^(company|person)$")
|
||||
company_name: str | None = Field(None, max_length=255)
|
||||
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)
|
||||
mobile: str | None = Field(None, max_length=50)
|
||||
website: str | None = Field(None, max_length=500)
|
||||
billing_street: str | None = Field(None, max_length=255)
|
||||
billing_number: str | None = Field(None, max_length=20)
|
||||
billing_postalcode: str | None = Field(None, max_length=20)
|
||||
billing_city: str | None = Field(None, max_length=100)
|
||||
billing_country: str | None = Field(None, max_length=100)
|
||||
shipping_street: str | None = Field(None, max_length=255)
|
||||
shipping_number: str | None = Field(None, max_length=20)
|
||||
shipping_postalcode: str | None = Field(None, max_length=20)
|
||||
shipping_city: str | None = Field(None, max_length=100)
|
||||
shipping_country: str | None = Field(None, max_length=100)
|
||||
tax_number: str | None = Field(None, max_length=50)
|
||||
note: str | None = None
|
||||
tag_ids: list[str] | None = None
|
||||
|
||||
|
||||
class ContactResponse(BaseModel):
|
||||
"""Public contact representation with tags."""
|
||||
id: str
|
||||
account_id: str
|
||||
type: str
|
||||
company_name: str | None = None
|
||||
first_name: str | None = None
|
||||
last_name: str | None = None
|
||||
email: str | None = None
|
||||
phone: str | None = None
|
||||
mobile: str | None = None
|
||||
website: str | None = None
|
||||
billing_street: str | None = None
|
||||
billing_number: str | None = None
|
||||
billing_postalcode: str | None = None
|
||||
billing_city: str | None = None
|
||||
billing_country: str | None = None
|
||||
shipping_street: str | None = None
|
||||
shipping_number: str | None = None
|
||||
shipping_postalcode: str | None = None
|
||||
shipping_city: str | None = None
|
||||
shipping_country: str | None = None
|
||||
tax_number: str | None = None
|
||||
note: str | None = None
|
||||
created_at: str
|
||||
updated_at: str
|
||||
tags: list[TagResponse] = []
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ContactListResponse(BaseModel):
|
||||
"""Paginated list of contacts."""
|
||||
items: list[ContactResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
@@ -0,0 +1,94 @@
|
||||
"""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
|
||||
@@ -0,0 +1,95 @@
|
||||
"""Pydantic schemas for Equipment (inventory catalog)."""
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class EquipmentCreateRequest(BaseModel):
|
||||
"""Request body for creating new equipment."""
|
||||
name: str = Field(..., max_length=255)
|
||||
category: str | None = Field(None, max_length=100)
|
||||
brand: str | None = Field(None, max_length=255)
|
||||
serial_number: str | None = Field(None, max_length=100)
|
||||
barcode: str | None = Field(None, max_length=100)
|
||||
qr_code: str | None = Field(None, max_length=500)
|
||||
status: str = Field("available", max_length=20)
|
||||
purchase_price: float | None = None
|
||||
current_value: float | None = None
|
||||
weight_kg: float | None = None
|
||||
dimensions: str | None = Field(None, max_length=255)
|
||||
power_watt: float | None = None
|
||||
notes: str | None = None
|
||||
custom_fields: str | None = None
|
||||
location_id: str | None = None
|
||||
supplier_id: str | None = None
|
||||
|
||||
|
||||
class EquipmentUpdateRequest(BaseModel):
|
||||
"""Request body for updating existing equipment."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
category: str | None = Field(None, max_length=100)
|
||||
brand: str | None = Field(None, max_length=255)
|
||||
serial_number: str | None = Field(None, max_length=100)
|
||||
barcode: str | None = Field(None, max_length=100)
|
||||
qr_code: str | None = Field(None, max_length=500)
|
||||
status: str | None = Field(None, max_length=20)
|
||||
purchase_price: float | None = None
|
||||
current_value: float | None = None
|
||||
weight_kg: float | None = None
|
||||
dimensions: str | None = Field(None, max_length=255)
|
||||
power_watt: float | None = None
|
||||
notes: str | None = None
|
||||
custom_fields: str | None = None
|
||||
location_id: str | None = None
|
||||
supplier_id: str | None = None
|
||||
|
||||
|
||||
class LocationRef(BaseModel):
|
||||
"""Minimal stock location reference."""
|
||||
id: str
|
||||
name: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class SupplierRef(BaseModel):
|
||||
"""Minimal supplier (contact) reference."""
|
||||
id: str
|
||||
name: str | None = None
|
||||
company_name: str | None = None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class EquipmentResponse(BaseModel):
|
||||
"""Public equipment representation."""
|
||||
id: str
|
||||
account_id: str
|
||||
name: str
|
||||
category: str | None = None
|
||||
brand: str | None = None
|
||||
serial_number: str | None = None
|
||||
barcode: str | None = None
|
||||
qr_code: str | None = None
|
||||
status: str
|
||||
purchase_price: float | None = None
|
||||
current_value: float | None = None
|
||||
weight_kg: float | None = None
|
||||
dimensions: str | None = None
|
||||
power_watt: float | None = None
|
||||
notes: str | None = None
|
||||
custom_fields: str | None = None
|
||||
location: LocationRef | None = None
|
||||
supplier: SupplierRef | None = None
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class EquipmentListResponse(BaseModel):
|
||||
"""Paginated list of equipment."""
|
||||
items: list[EquipmentResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Pydantic schemas for EquipmentGroup (Bundles)."""
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class EquipmentGroupItem(BaseModel):
|
||||
"""An item inside a bundle with quantity."""
|
||||
equipment_id: str
|
||||
name: str | None = None
|
||||
quantity: float = 1.0
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class EquipmentGroupCreateRequest(BaseModel):
|
||||
"""Request body for creating a new equipment group/bundle."""
|
||||
name: str = Field(..., max_length=255)
|
||||
description: str | None = None
|
||||
daily_rate: float | None = None
|
||||
default_location_id: str | None = None
|
||||
items: list[EquipmentGroupItem] = []
|
||||
|
||||
|
||||
class EquipmentGroupUpdateRequest(BaseModel):
|
||||
"""Request body for updating an equipment group."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
description: str | None = None
|
||||
daily_rate: float | None = None
|
||||
default_location_id: str | None = None
|
||||
items: list[EquipmentGroupItem] | None = None
|
||||
|
||||
|
||||
class EquipmentGroupResponse(BaseModel):
|
||||
"""Public equipment group representation."""
|
||||
id: str
|
||||
account_id: str
|
||||
name: str
|
||||
description: str | None = None
|
||||
daily_rate: float | None = None
|
||||
default_location: LocationRef | None = None
|
||||
items: list[EquipmentGroupItem] = []
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class EquipmentGroupListResponse(BaseModel):
|
||||
"""Paginated list of equipment groups."""
|
||||
items: list[EquipmentGroupResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
|
||||
|
||||
# Need LocationRef for EquipmentGroupResponse
|
||||
from app.schemas.equipment import LocationRef # noqa: E402, F811
|
||||
@@ -0,0 +1,170 @@
|
||||
"""Pydantic schemas for Project, SubProject, ProjectFunctionGroup, ProjectFunction."""
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# ===== Project Schemas =====
|
||||
|
||||
class ProjectCreateRequest(BaseModel):
|
||||
"""Request body for creating a new project."""
|
||||
name: str = Field(..., max_length=255)
|
||||
description: str | None = None
|
||||
status: str = Field("draft", max_length=20)
|
||||
start_date: datetime | None = None
|
||||
end_date: datetime | None = None
|
||||
budget: float | None = None
|
||||
total_costs: float = 0.0
|
||||
notes: str | None = None
|
||||
custom_fields: str | None = None
|
||||
custom_field_defs: str | None = None
|
||||
|
||||
|
||||
class ProjectUpdateRequest(BaseModel):
|
||||
"""Request body for updating an existing project."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
description: str | None = None
|
||||
status: str | None = Field(None, max_length=20)
|
||||
start_date: datetime | None = None
|
||||
end_date: datetime | None = None
|
||||
budget: float | None = None
|
||||
total_costs: float | None = None
|
||||
notes: str | None = None
|
||||
custom_fields: str | None = None
|
||||
custom_field_defs: str | None = None
|
||||
|
||||
|
||||
class ProjectResponse(BaseModel):
|
||||
"""Public project representation."""
|
||||
id: str
|
||||
account_id: str
|
||||
name: str
|
||||
description: str | None = None
|
||||
status: str
|
||||
start_date: datetime | None = None
|
||||
end_date: datetime | None = None
|
||||
budget: float | None = None
|
||||
total_costs: float = 0.0
|
||||
notes: str | None = None
|
||||
custom_fields: str | None = None
|
||||
custom_field_defs: str | None = None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ProjectListResponse(BaseModel):
|
||||
"""Paginated list of projects."""
|
||||
items: list[ProjectResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
|
||||
|
||||
# ===== SubProject Schemas =====
|
||||
|
||||
class SubProjectCreateRequest(BaseModel):
|
||||
"""Request body for creating a subproject."""
|
||||
name: str = Field(..., max_length=255)
|
||||
parent_id: str | None = None
|
||||
sort_order: int = 0
|
||||
|
||||
|
||||
class SubProjectUpdateRequest(BaseModel):
|
||||
"""Request body for updating a subproject."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
parent_id: str | None = None
|
||||
sort_order: int | None = None
|
||||
|
||||
|
||||
class SubProjectResponse(BaseModel):
|
||||
"""Public subproject representation."""
|
||||
id: str
|
||||
name: str
|
||||
project_id: str
|
||||
parent_id: str | None = None
|
||||
sort_order: int = 0
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class SubProjectListResponse(BaseModel):
|
||||
"""Paginated list of subprojects."""
|
||||
items: list[SubProjectResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
|
||||
|
||||
# ===== ProjectFunctionGroup Schemas =====
|
||||
|
||||
class ProjectFunctionGroupCreateRequest(BaseModel):
|
||||
"""Request body for creating a function group."""
|
||||
name: str = Field(..., max_length=255)
|
||||
sort_order: int = 0
|
||||
|
||||
|
||||
class ProjectFunctionGroupUpdateRequest(BaseModel):
|
||||
"""Request body for updating a function group."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
sort_order: int | None = None
|
||||
|
||||
|
||||
class ProjectFunctionGroupResponse(BaseModel):
|
||||
"""Public function group representation."""
|
||||
id: str
|
||||
name: str
|
||||
project_id: str
|
||||
sort_order: int = 0
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ProjectFunctionGroupListResponse(BaseModel):
|
||||
"""Paginated list of function groups."""
|
||||
items: list[ProjectFunctionGroupResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
|
||||
|
||||
# ===== ProjectFunction Schemas =====
|
||||
|
||||
class ProjectFunctionCreateRequest(BaseModel):
|
||||
"""Request body for creating a project function."""
|
||||
name: str = Field(..., max_length=255)
|
||||
quantity: float = 1.0
|
||||
daily_costs: float = 0.0
|
||||
total_costs: float = 0.0
|
||||
sort_order: int = 0
|
||||
|
||||
|
||||
class ProjectFunctionUpdateRequest(BaseModel):
|
||||
"""Request body for updating a project function."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
quantity: float | None = None
|
||||
daily_costs: float | None = None
|
||||
total_costs: float | None = None
|
||||
sort_order: int | None = None
|
||||
|
||||
|
||||
class ProjectFunctionResponse(BaseModel):
|
||||
"""Public project function representation."""
|
||||
id: str
|
||||
name: str
|
||||
function_group_id: str
|
||||
quantity: float = 1.0
|
||||
daily_costs: float = 0.0
|
||||
total_costs: float = 0.0
|
||||
sort_order: int = 0
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ProjectFunctionListResponse(BaseModel):
|
||||
"""Paginated list of project functions."""
|
||||
items: list[ProjectFunctionResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Pydantic schemas for role management."""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class RoleCreateRequest(BaseModel):
|
||||
"""Request body for creating a new role."""
|
||||
name: str = Field(..., min_length=2, max_length=100)
|
||||
description: str | None = None
|
||||
permissions: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class RoleUpdateRequest(BaseModel):
|
||||
"""Request body for updating an existing role."""
|
||||
name: str | None = Field(None, min_length=2, max_length=100)
|
||||
description: str | None = None
|
||||
permissions: list[str] | None = None
|
||||
|
||||
|
||||
class RoleResponse(BaseModel):
|
||||
"""Public role representation."""
|
||||
id: str
|
||||
account_id: str
|
||||
name: str
|
||||
description: str | None = None
|
||||
permissions: list[str]
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Pydantic schemas for StockLocation."""
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class StockLocationCreateRequest(BaseModel):
|
||||
"""Request body for creating a new stock location."""
|
||||
name: str = Field(..., max_length=255)
|
||||
address: str | None = Field(None, max_length=500)
|
||||
is_default: bool = False
|
||||
|
||||
|
||||
class StockLocationUpdateRequest(BaseModel):
|
||||
"""Request body for updating a stock location."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
address: str | None = Field(None, max_length=500)
|
||||
is_default: bool | None = None
|
||||
|
||||
|
||||
class StockLocationResponse(BaseModel):
|
||||
"""Public stock location representation."""
|
||||
id: str
|
||||
account_id: str
|
||||
name: str
|
||||
address: str | None = None
|
||||
is_default: bool
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class StockLocationListResponse(BaseModel):
|
||||
"""Paginated list of stock locations."""
|
||||
items: list[StockLocationResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Pydantic schemas for user management."""
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
|
||||
class UserCreateRequest(BaseModel):
|
||||
"""Request body for creating a new user (invite)."""
|
||||
email: EmailStr
|
||||
full_name: str = Field(..., min_length=2, max_length=255)
|
||||
password: str = Field(..., min_length=8, max_length=128)
|
||||
role_id: str | None = None
|
||||
|
||||
|
||||
class UserUpdateRequest(BaseModel):
|
||||
"""Request body for updating an existing user."""
|
||||
full_name: str | None = Field(None, min_length=2, max_length=255)
|
||||
role_id: str | None = None
|
||||
is_active: bool | None = None
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
"""Public user representation (no password hash)."""
|
||||
id: str
|
||||
account_id: str
|
||||
email: str
|
||||
full_name: str
|
||||
is_active: bool
|
||||
role_id: str | None = None
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class UserListResponse(BaseModel):
|
||||
"""Paginated list of users."""
|
||||
items: list[UserResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
@@ -0,0 +1,107 @@
|
||||
"""Pydantic schemas for Vehicles and VehicleAssignments."""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class VehicleAssignmentResponse(BaseModel):
|
||||
"""Public vehicle assignment representation."""
|
||||
id: str
|
||||
vehicle_id: str
|
||||
project_id: str | None = None
|
||||
start_date: str
|
||||
end_date: str
|
||||
status: str
|
||||
notes: str | None = None
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class VehicleCreateRequest(BaseModel):
|
||||
"""Request body for creating a new vehicle."""
|
||||
name: str = Field(..., max_length=255)
|
||||
license_plate: str | None = Field(None, max_length=50)
|
||||
brand: str | None = Field(None, max_length=100)
|
||||
model: str | None = Field(None, max_length=100)
|
||||
year: int | None = None
|
||||
color: str | None = Field(None, max_length=50)
|
||||
vehicle_type: str | None = Field(None, max_length=50)
|
||||
payload_capacity_kg: float | None = None
|
||||
load_volume_m3: float | None = None
|
||||
fuel_type: str | None = Field(None, max_length=30)
|
||||
is_active: bool = True
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class VehicleUpdateRequest(BaseModel):
|
||||
"""Request body for updating a vehicle."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
license_plate: str | None = Field(None, max_length=50)
|
||||
brand: str | None = Field(None, max_length=100)
|
||||
model: str | None = Field(None, max_length=100)
|
||||
year: int | None = None
|
||||
color: str | None = Field(None, max_length=50)
|
||||
vehicle_type: str | None = Field(None, max_length=50)
|
||||
payload_capacity_kg: float | None = None
|
||||
load_volume_m3: float | None = None
|
||||
fuel_type: str | None = Field(None, max_length=30)
|
||||
is_active: bool | None = None
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class VehicleResponse(BaseModel):
|
||||
"""Public vehicle representation."""
|
||||
id: str
|
||||
account_id: str
|
||||
name: str
|
||||
license_plate: str | None = None
|
||||
brand: str | None = None
|
||||
model: str | None = None
|
||||
year: int | None = None
|
||||
color: str | None = None
|
||||
vehicle_type: str | None = None
|
||||
payload_capacity_kg: float | None = None
|
||||
load_volume_m3: float | None = None
|
||||
fuel_type: str | None = None
|
||||
is_active: bool
|
||||
notes: str | None = None
|
||||
assignments: list[VehicleAssignmentResponse] = []
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class VehicleListResponse(BaseModel):
|
||||
"""Paginated list of vehicles."""
|
||||
items: list[VehicleResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
|
||||
|
||||
class VehicleAssignmentCreateRequest(BaseModel):
|
||||
"""Request body for creating a vehicle assignment."""
|
||||
vehicle_id: str
|
||||
project_id: str | None = None
|
||||
start_date: str = Field(..., description="ISO datetime")
|
||||
end_date: str = Field(..., description="ISO datetime")
|
||||
status: str = Field("assigned", max_length=20)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class VehicleAssignmentUpdateRequest(BaseModel):
|
||||
"""Request body for updating a vehicle assignment."""
|
||||
start_date: str | None = None
|
||||
end_date: str | None = None
|
||||
status: str | None = Field(None, max_length=20)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class VehicleAssignmentListResponse(BaseModel):
|
||||
"""Paginated list of vehicle assignments."""
|
||||
items: list[VehicleAssignmentResponse]
|
||||
total: int
|
||||
page: int
|
||||
size: int
|
||||
Reference in New Issue
Block a user