This commit is contained in:
2023-11-30 10:38:41 +03:00
parent 537d588853
commit 2d3f7a51b4
10 changed files with 92 additions and 80 deletions

View File

@@ -7,9 +7,9 @@ from enum import Enum as Enumeration
class InviteStatus(Enumeration):
PENDING = 0
ACCEPTED = 1
REJECTED = 2
PENDING = "PENDING"
ACCEPTED = "ACCEPTED"
REJECTED = "REJECTED"
class Invite(Base):
@@ -18,7 +18,7 @@ class Invite(Base):
inviter_id = Column(ForeignKey("author.id"), nullable=False, index=True)
author_id = Column(ForeignKey("author.id"), nullable=False, index=True)
shout_id = Column(ForeignKey("shout.id"), nullable=False, index=True)
status = Column(Enum(InviteStatus), default=InviteStatus.PENDING)
status = Column(Enum(InviteStatus), default=InviteStatus.PENDING.value)
inviter = relationship(Author, foreign_keys=[inviter_id])
author = relationship(Author, foreign_keys=[author_id])

View File

@@ -10,20 +10,20 @@ class ReactionKind(Enumeration):
# TYPE = <reaction index> # rating diff
# editor mode
AGREE = 1 # +1
DISAGREE = 2 # -1
ASK = 3 # +0
PROPOSE = 4 # +0
PROOF = 5 # +1
DISPROOF = 6 # -1
ACCEPT = 7 # +1
REJECT = 8 # -1
AGREE = "AGREE" # +1
DISAGREE = "DISAGREE" # -1
ASK = "ASK" # +0
PROPOSE = "PROPOSE" # +0
PROOF = "PROOF" # +1
DISPROOF = "DISPROOF" # -1
ACCEPT = "ACCEPT" # +1
REJECT = "REJECT" # -1
# public feed
QUOTE = 9 # +0 TODO: use to bookmark in collection
COMMENT = 0 # +0
LIKE = 11 # +1
DISLIKE = 12 # -1
QUOTE = "QUOTE" # +0 TODO: use to bookmark in collection
COMMENT = "COMMENT" # +0
LIKE = "LIKE" # +1
DISLIKE = "DISLIKE" # -1
class Reaction(Base):
@@ -31,13 +31,13 @@ class Reaction(Base):
body = Column(String, default="", comment="Reaction Body")
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
created_by = Column(ForeignKey("author.id"), nullable=False, index=True)
updated_at = Column(Integer, nullable=True, comment="Updated at")
deleted_at = Column(Integer, nullable=True, comment="Deleted at")
deleted_by = Column(ForeignKey("author.id"), nullable=True, index=True)
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
quote = Column(String, nullable=True, comment="Original quoted text")
kind = Column(Enum(ReactionKind), nullable=False)
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
created_by = Column(ForeignKey("author.id"), nullable=False, index=True)
kind = Column(Enum(ReactionKind), nullable=False, index=True)
oid = Column(String)

View File

@@ -48,9 +48,9 @@ class ShoutCommunity(Base):
class ShoutVisibility(Enumeration):
AUTHORS = 0
COMMUNITY = 1
PUBLIC = 2
AUTHORS = "AUTHORS"
COMMUNITY = "COMMUNITY"
PUBLIC = "PUBLIC"
class Shout(Base):
@@ -78,7 +78,7 @@ class Shout(Base):
communities = relationship(lambda: Community, secondary="shout_community")
reactions = relationship(lambda: Reaction)
visibility = Column(Enum(ShoutVisibility), default=ShoutVisibility.AUTHORS)
visibility = Column(Enum(ShoutVisibility), default=ShoutVisibility.AUTHORS.value)
lang = Column(String, nullable=False, default="ru", comment="Language")
version_of = Column(ForeignKey("shout.id"), nullable=True)