
- Implemented user authentication with JWT tokens - Created comprehensive task management with CRUD operations - Added category system for task organization - Set up SQLite database with SQLAlchemy ORM - Configured Alembic for database migrations - Added API documentation with OpenAPI/Swagger - Implemented proper authorization and user scoping - Created health check and root endpoints - Updated README with complete documentation
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, Enum
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from enum import Enum as PyEnum
|
|
from app.db.base import Base
|
|
|
|
class TaskStatus(PyEnum):
|
|
PENDING = "pending"
|
|
IN_PROGRESS = "in_progress"
|
|
COMPLETED = "completed"
|
|
CANCELLED = "cancelled"
|
|
|
|
class TaskPriority(PyEnum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
URGENT = "urgent"
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
status = Column(Enum(TaskStatus), default=TaskStatus.PENDING)
|
|
priority = Column(Enum(TaskPriority), default=TaskPriority.MEDIUM)
|
|
due_date = Column(DateTime(timezone=True), nullable=True)
|
|
completed_at = Column(DateTime(timezone=True), nullable=True)
|
|
owner_id = Column(Integer, ForeignKey("users.id"))
|
|
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
owner = relationship("User", back_populates="tasks")
|
|
category = relationship("Category", back_populates="tasks") |