core/orm/reaction.py

48 lines
1.7 KiB
Python
Raw Normal View History

2022-09-19 13:50:43 +00:00
from enum import Enum as Enumeration
2023-10-26 21:07:35 +00:00
from sqlalchemy import Column, DateTime, Enum, ForeignKey, String, func
2022-11-09 11:46:00 +00:00
2023-10-26 21:07:35 +00:00
from base.orm import Base
2022-09-19 13:50:43 +00:00
class ReactionKind(Enumeration):
AGREE = 1 # +1
DISAGREE = 2 # -1
PROOF = 3 # +1
DISPROOF = 4 # -1
ASK = 5 # +0
2022-09-19 13:50:43 +00:00
PROPOSE = 6 # +0
QUOTE = 7 # +0 bookmark
COMMENT = 8 # +0
ACCEPT = 9 # +1
REJECT = 0 # -1
LIKE = 11 # +1
DISLIKE = 12 # -1
2023-02-13 15:03:09 +00:00
REMARK = 13 # 0
FOOTNOTE = 14 # 0
2022-09-19 13:50:43 +00:00
# TYPE = <reaction index> # rating diff
2022-09-03 10:50:14 +00:00
class Reaction(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "reaction"
body = Column(String, nullable=True, comment="Reaction Body")
createdAt = Column(
DateTime(timezone=True), nullable=False, server_default=func.now(), comment="Created at"
)
2023-10-30 21:00:55 +00:00
createdBy: Column = Column(ForeignKey("user.id"), nullable=False, index=True, comment="Sender")
updatedAt = Column(DateTime(timezone=True), nullable=True, comment="Updated at")
2023-10-30 21:00:55 +00:00
updatedBy: Column = Column(
ForeignKey("user.id"), nullable=True, index=True, comment="Last Editor"
)
deletedAt = Column(DateTime(timezone=True), nullable=True, comment="Deleted at")
2023-10-30 21:00:55 +00:00
deletedBy: Column = Column(
ForeignKey("user.id"), nullable=True, index=True, comment="Deleted by"
)
shout: Column = Column(ForeignKey("shout.id"), nullable=False, index=True)
replyTo: Column = Column(
2023-10-26 21:07:35 +00:00
ForeignKey("reaction.id"), nullable=True, comment="Reply to reaction ID"
)
2022-09-04 17:20:38 +00:00
range = Column(String, nullable=True, comment="Range in format <start index>:<end>")
2022-09-03 10:50:14 +00:00
kind = Column(Enum(ReactionKind), nullable=False, comment="Reaction kind")
oid = Column(String, nullable=True, comment="Old ID")