type fix
This commit is contained in:
@@ -6,6 +6,7 @@ from orm.topic import Topic
|
||||
from orm.notification import Notification
|
||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutRating, ShoutViewByDay
|
||||
from orm.base import Base, engine
|
||||
from orm.comment import Comment
|
||||
|
||||
__all__ = ["User", "Role", "Operation", "Permission", "Message", "Shout", "Topic", "Notification"]
|
||||
|
||||
|
@@ -2,8 +2,8 @@ from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from orm import Permission
|
||||
from orm.base import Base
|
||||
|
||||
class CommentRating(Base):
|
||||
@@ -16,17 +16,17 @@ class CommentRating(Base):
|
||||
value = Column(Integer)
|
||||
|
||||
class Comment(Base):
|
||||
__tablename__ = 'Comment'
|
||||
__tablename__ = 'comment'
|
||||
|
||||
author: int = Column(ForeignKey("user.id"), nullable=False, comment="Sender")
|
||||
body: str = Column(String, nullable=False, comment="Body")
|
||||
createdAt = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||
updatedAt = Column(DateTime, nullable=True, comment="Updated at")
|
||||
deletedAt = Column(DateTime, nullable=True, comment="Deleted at")
|
||||
deletedBy = Column(ForeignKey("user.id"), nullable=True, comment="Deleted by")
|
||||
shout: int = Column(ForeignKey("shout.id"), nullable=True, comment="Shout ID")
|
||||
author: int = Column(ForeignKey("user.id"), nullable=False, comment="Sender")
|
||||
body: str = Column(String, nullable=False, comment="Body")
|
||||
createdAt = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||
updatedAt = Column(DateTime, nullable=True, comment="Updated at")
|
||||
deletedAt = Column(DateTime, nullable=True, comment="Deleted at")
|
||||
deletedBy = Column(ForeignKey("user.id"), nullable=True, comment="Deleted by")
|
||||
shout: int = Column(ForeignKey("shout.id"), nullable=True, comment="Shout ID")
|
||||
ratings = relationship(CommentRating, foreign_keys=CommentRating.comment_id)
|
||||
old_id: str = Column(String, nullable = True)
|
||||
|
||||
|
||||
|
||||
# TODO: work in progress, udpate this code
|
||||
# TODO: work in progress, udpate this code
|
||||
|
15
orm/shout.py
15
orm/shout.py
@@ -2,7 +2,8 @@ from typing import List
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Table, Column, Integer, String, ForeignKey, DateTime, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
from orm import Permission, User, Topic, Comment
|
||||
from orm import Permission, User, Topic
|
||||
from orm.comment import Comment
|
||||
from orm.base import Base
|
||||
|
||||
class ShoutAuthor(Base):
|
||||
@@ -11,13 +12,13 @@ class ShoutAuthor(Base):
|
||||
id = None
|
||||
shout = Column(ForeignKey('shout.id'), primary_key = True)
|
||||
user = Column(ForeignKey('user.id'), primary_key = True)
|
||||
|
||||
|
||||
class ShoutViewer(Base):
|
||||
__tablename__ = "shout_viewer"
|
||||
|
||||
id = None
|
||||
shout = Column(ForeignKey('shout.id'), primary_key = True)
|
||||
user = Column(ForeignKey('user.id'), primary_key = True)
|
||||
__tablename__ = "shout_viewer"
|
||||
|
||||
id = None
|
||||
shout = Column(ForeignKey('shout.id'), primary_key = True)
|
||||
user = Column(ForeignKey('user.id'), primary_key = True)
|
||||
|
||||
class ShoutTopic(Base):
|
||||
__tablename__ = 'shout_topic'
|
||||
|
Reference in New Issue
Block a user