
- Create Category and Tag models - Create TodoTag association table - Add category_id to Todo model - Create Alembic migration for new tables - Create schemas for Category and Tag - Update Todo schemas to include Category and Tags - Create CRUD operations for Categories and Tags - Update Todo CRUD operations to handle categories and tags - Create API endpoints for categories and tags - Update Todo API endpoints with category and tag filtering - Update documentation
39 lines
709 B
Python
39 lines
709 B
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class CategoryBase(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
|
|
|
|
# Properties to receive on category creation
|
|
class CategoryCreate(CategoryBase):
|
|
name: str
|
|
|
|
|
|
# Properties to receive on category update
|
|
class CategoryUpdate(CategoryBase):
|
|
pass
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class CategoryInDBBase(CategoryBase):
|
|
id: int
|
|
name: str
|
|
owner_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Category(CategoryInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class CategoryInDB(CategoryInDBBase):
|
|
pass |