36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TaskBase(BaseModel):
|
|
title: str = Field(..., max_length=255, description="Title of the task")
|
|
description: Optional[str] = Field(None, description="Detailed description of the task")
|
|
completed: bool = Field(False, description="Whether the task is completed")
|
|
priority: int = Field(0, ge=0, le=2, description="Priority level (0: Low, 1: Medium, 2: High)")
|
|
due_date: Optional[datetime] = Field(None, description="Due date of the task")
|
|
|
|
|
|
class TaskCreate(TaskBase):
|
|
pass
|
|
|
|
|
|
class TaskUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, max_length=255, description="Title of the task")
|
|
description: Optional[str] = Field(None, description="Detailed description of the task")
|
|
completed: Optional[bool] = Field(None, description="Whether the task is completed")
|
|
priority: Optional[int] = Field(None, ge=0, le=2, description="Priority level (0: Low, 1: Medium, 2: High)")
|
|
due_date: Optional[datetime] = Field(None, description="Due date of the task")
|
|
|
|
|
|
class TaskInDB(TaskBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class Task(TaskInDB):
|
|
pass |