separate CommentFlag from CreatedBase

inherit Base = declarative_base() directly instead
key to understanding was https://stackoverflow.com/questions/9088957/sqlalchemy-cannot-find-a-class-name
This commit is contained in:
Viet Than 2023-07-11 23:43:39 -04:00
parent 82d404bafb
commit 14d5a012ac
2 changed files with 6 additions and 4 deletions

View file

@ -71,7 +71,7 @@ class Comment(CreatedBase):
viewonly=True) viewonly=True)
reports = relationship("CommentFlag", reports = relationship("CommentFlag",
primaryjoin="CommentFlag.comment_id == Comment.id", primaryjoin="CommentFlag.comment_id == Comment.id",
order_by="CommentFlag.created_utc", order_by="CommentFlag.created_timestampz",
viewonly=True) viewonly=True)
notes = relationship("UserNote", back_populates="comment") notes = relationship("UserNote", back_populates="comment")

View file

@ -1,9 +1,11 @@
from sqlalchemy import * from sqlalchemy import *
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship, declarative_base
from files.classes.base import CreatedBase from files.classes.base import CreatedBase, Base
from files.helpers.lazy import lazy from files.helpers.lazy import lazy
from files.helpers.config.const import * from files.helpers.config.const import *
class Flag(CreatedBase): class Flag(CreatedBase):
__tablename__ = "flags" __tablename__ = "flags"
@ -24,7 +26,7 @@ class Flag(CreatedBase):
return self.reason return self.reason
class CommentFlag(CreatedBase): class CommentFlag(Base):
__tablename__ = "commentflags" __tablename__ = "commentflags"
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)