Implement BaseModel class, TimestampMixin, TzDateTime type; cleanup Task model

This commit is contained in:
Lexi / Zoe 2022-04-15 21:45:10 +02:00
parent 7ce43a2bfe
commit 252c15acbd
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
15 changed files with 223 additions and 42 deletions

View file

@ -1,25 +1,19 @@
from sqlalchemy import Column, Integer, String, Text
from sqlalchemy import Column, String, Text
from tofu_api.common.database import Col
from tofu_api.common.database.mixins import TimestampMixin
from .base import BaseModel
class Task(BaseModel):
class Task(TimestampMixin, BaseModel):
"""
Database model for tasks.
"""
__tablename__ = 'tasks'
__tablename__ = 'task'
id: int = Column(Integer, nullable=False, primary_key=True)
# TODO: created_at, modified_at
title: Col[str] = Column(String(255), nullable=False)
description: Col[str] = Column(Text, nullable=False, default='')
title: str = Column(String(255), nullable=False)
description: str = Column(Text, nullable=False, default='')
def to_dict(self) -> dict:
# TODO: Implement a generic to_dict() in the base model
return {
'id': self.id,
'title': self.title,
'description': self.description,
}
def __repr__(self):
return self._repr(id=self.id, title=self.title)