
This commit includes: - Project structure and configuration - Database models for tasks, users, and categories - Authentication system with JWT - CRUD endpoints for tasks and categories - Search, filter, and sorting functionality - Health check endpoint - Alembic migration setup - Documentation
43 lines
844 B
Python
43 lines
844 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class CategoryBase(BaseModel):
|
|
name: Optional[str] = None
|
|
color: Optional[str] = "#FFFFFF"
|
|
|
|
|
|
# Properties to receive on category creation
|
|
class CategoryCreate(CategoryBase):
|
|
name: str = Field(..., min_length=1, max_length=50)
|
|
|
|
|
|
# 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
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Category(CategoryInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class CategoryInDB(CategoryInDBBase):
|
|
pass
|