
- Add parent_id field to Todo model with self-referential foreign key - Add parent/children relationships and is_subtask property - Update TodoCreate/TodoUpdate schemas to include parent_id - Add subtasks list to Todo schema and create SubtaskCreate schema - Enhance get_todos CRUD function with parent_id filtering - Add subtask-specific CRUD functions: get_subtasks, create_subtask, move_subtask - Add API endpoints for subtask management - Create migration for adding parent_id column - Update imports and fix circular dependencies - Ensure proper cycle prevention and validation Features added: - GET /todos/{todo_id}/subtasks - Get all subtasks for a todo - POST /todos/{todo_id}/subtasks - Create a new subtask - PUT /subtasks/{subtask_id}/move - Move subtask or convert to main todo - Query parameter parent_id for filtering by parent - Query parameter include_subtasks for excluding subtasks from main list
37 lines
786 B
Python
37 lines
786 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TagBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=50, description="Tag name")
|
|
color: str = Field(
|
|
default="#3B82F6", pattern=r"^#[0-9A-Fa-f]{6}$", description="Hex color code"
|
|
)
|
|
|
|
|
|
class TagCreate(TagBase):
|
|
pass
|
|
|
|
|
|
class TagUpdate(BaseModel):
|
|
name: Optional[str] = Field(
|
|
None, min_length=1, max_length=50, description="Tag name"
|
|
)
|
|
color: Optional[str] = Field(
|
|
None, pattern=r"^#[0-9A-Fa-f]{6}$", description="Hex color code"
|
|
)
|
|
|
|
|
|
class Tag(TagBase):
|
|
id: int
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class TagListResponse(BaseModel):
|
|
items: list[Tag]
|
|
total: int
|