5cc576cec9
- Recipe model: add image_path field for recipe-level image
- RecipeSubtask model: add image_path for per-subtask detail images
- Schemas: add image_path to create/update/response for recipe and subtask
- Task router: pass image_path when creating tasks and subtasks
- Recipe service: copy image_path in versioning and update-in-place
- Users router: add PUT /{user_id}/password endpoint (admin only)
- User schema: add UserPasswordChange model
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
93 lines
3.0 KiB
Python
93 lines
3.0 KiB
Python
"""Pydantic schemas for RecipeTask and RecipeSubtask operations."""
|
|
from typing import Any, Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class SubtaskCreate(BaseModel):
|
|
"""Schema for creating a subtask."""
|
|
marker_number: int = Field(..., ge=1)
|
|
description: str = Field(..., min_length=1, max_length=500)
|
|
measurement_type: Optional[str] = Field(None, max_length=100)
|
|
nominal: Optional[float] = None
|
|
utl: Optional[float] = None
|
|
uwl: Optional[float] = None
|
|
lwl: Optional[float] = None
|
|
ltl: Optional[float] = None
|
|
unit: str = Field("mm", max_length=20)
|
|
image_path: Optional[str] = Field(None, max_length=500)
|
|
|
|
|
|
class SubtaskUpdate(BaseModel):
|
|
"""Schema for updating a subtask."""
|
|
description: Optional[str] = Field(None, min_length=1, max_length=500)
|
|
measurement_type: Optional[str] = Field(None, max_length=100)
|
|
nominal: Optional[float] = None
|
|
utl: Optional[float] = None
|
|
uwl: Optional[float] = None
|
|
lwl: Optional[float] = None
|
|
ltl: Optional[float] = None
|
|
unit: Optional[str] = Field(None, max_length=20)
|
|
image_path: Optional[str] = Field(None, max_length=500)
|
|
|
|
|
|
class SubtaskResponse(BaseModel):
|
|
"""Schema for subtask response."""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
task_id: int
|
|
marker_number: int
|
|
description: str
|
|
measurement_type: Optional[str] = None
|
|
nominal: Optional[float] = None
|
|
utl: Optional[float] = None
|
|
uwl: Optional[float] = None
|
|
lwl: Optional[float] = None
|
|
ltl: Optional[float] = None
|
|
unit: str
|
|
image_path: Optional[str] = None
|
|
|
|
|
|
class TaskCreate(BaseModel):
|
|
"""Schema for creating a task."""
|
|
title: str = Field(..., min_length=1, max_length=255)
|
|
directive: Optional[str] = None
|
|
description: Optional[str] = None
|
|
file_path: Optional[str] = Field(None, max_length=500)
|
|
file_type: Optional[str] = Field(None, pattern="^(image|pdf)$")
|
|
annotations_json: Optional[dict[str, Any]] = None
|
|
subtasks: list[SubtaskCreate] = []
|
|
|
|
|
|
class TaskUpdate(BaseModel):
|
|
"""Schema for updating a task."""
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
directive: Optional[str] = None
|
|
description: Optional[str] = None
|
|
file_path: Optional[str] = Field(None, max_length=500)
|
|
file_type: Optional[str] = Field(None, pattern="^(image|pdf)$")
|
|
annotations_json: Optional[dict[str, Any]] = None
|
|
|
|
|
|
class TaskResponse(BaseModel):
|
|
"""Schema for task response."""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
version_id: int
|
|
recipe_id: Optional[int] = None
|
|
order_index: int
|
|
title: str
|
|
directive: Optional[str] = None
|
|
description: Optional[str] = None
|
|
file_path: Optional[str] = None
|
|
file_type: Optional[str] = None
|
|
annotations_json: Optional[dict[str, Any]] = None
|
|
subtasks: list[SubtaskResponse] = []
|
|
|
|
|
|
class TaskReorderRequest(BaseModel):
|
|
"""Schema for reordering tasks."""
|
|
task_ids: list[int] = Field(..., min_length=1)
|