
- Added subtask model with CRUD operations - Added reminder functionality to Todo model - Added endpoints for managing subtasks and reminders - Created new migration for subtasks and reminders - Updated documentation generated with BackendIM... (backend.im)
78 lines
1.9 KiB
Python
78 lines
1.9 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
class PriorityLevel(str, Enum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
class TagBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=50)
|
|
|
|
class TagCreate(TagBase):
|
|
pass
|
|
|
|
class TagResponse(TagBase):
|
|
id: int
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class SubtaskBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
completed: bool = False
|
|
|
|
class SubtaskCreate(SubtaskBase):
|
|
pass
|
|
|
|
class SubtaskUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
completed: Optional[bool] = None
|
|
|
|
class SubtaskResponse(SubtaskBase):
|
|
id: int
|
|
todo_id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class TodoBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
priority: PriorityLevel = PriorityLevel.MEDIUM
|
|
due_date: Optional[datetime] = None
|
|
remind_at: Optional[datetime] = None
|
|
|
|
class TodoCreate(TodoBase):
|
|
tag_ids: Optional[List[int]] = []
|
|
|
|
class TodoCreateWithTags(TodoBase):
|
|
tags: Optional[List[str]] = []
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
priority: Optional[PriorityLevel] = None
|
|
due_date: Optional[datetime] = None
|
|
remind_at: Optional[datetime] = None
|
|
tag_ids: Optional[List[int]] = None
|
|
|
|
class TodoResponse(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
tags: List[TagResponse] = []
|
|
subtasks: List[SubtaskResponse] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class HealthResponse(BaseModel):
|
|
status: str |