Spaces:
Sleeping
Sleeping
Download build/lib/models/todo.py from hashir-qt/tasklert-api: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/build/lib/models/todo.py
- Command line
-
hf download hf://spaces/hashir-qt/tasklert-api/build/lib/models/todo.py
-
curl -L -o todo.py https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/build/lib/models/todo.py
1.42 kB
| from datetime import datetime, timezone | |
| from pydantic import field_validator | |
| from sqlmodel import SQLModel, Field | |
| class Todo(SQLModel, table=True): | |
| id: int | None = Field(default=None, primary_key=True) | |
| title: str = Field(index=True) | |
| description: str | None = Field(default=None) | |
| completed: bool = False | |
| user_id: int = Field(foreign_key="user.id", index=True) | |
| created_at: datetime = Field( | |
| default_factory=lambda: datetime.now(timezone.utc) | |
| ) | |
| updated_at: datetime = Field( | |
| default_factory=lambda: datetime.now(timezone.utc) | |
| ) | |
| class TodoCreate(SQLModel): | |
| title: str | |
| description: str | None = None | |
| def title_length(cls, v: str) -> str: | |
| if not v or len(v) > 200: | |
| raise ValueError("Title must be 1-200 characters") | |
| return v | |
| def description_length(cls, v: str | None) -> str | None: | |
| if v is not None and len(v) > 1000: | |
| raise ValueError("Description must be 1000 characters or fewer") | |
| return v | |
| class TodoUpdate(SQLModel): | |
| title: str | None = None | |
| description: str | None = None | |
| completed: bool | None = None | |
| class TodoRead(SQLModel): | |
| id: int | |
| title: str | |
| description: str | None | |
| completed: bool | |
| user_id: int | |
| created_at: datetime | |
| updated_at: datetime | |