2022-07-21 11:58:50 +00:00
|
|
|
from datetime import datetime
|
2022-09-19 13:50:43 +00:00
|
|
|
from enum import Enum as Enumeration
|
2022-09-17 18:12:14 +00:00
|
|
|
|
2022-11-09 11:46:00 +00:00
|
|
|
from sqlalchemy import Column, DateTime, Enum, ForeignKey, String
|
|
|
|
|
2022-09-17 18:12:14 +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
|
2023-01-25 06:32:59 +00:00
|
|
|
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-01-25 06:32:59 +00:00
|
|
|
REMARK = 13 # 0
|
|
|
|
FOOTNOTE = 14 # 0
|
2022-09-19 13:50:43 +00:00
|
|
|
# TYPE = <reaction index> # rating diff
|
2022-07-21 11:58:50 +00:00
|
|
|
|
2022-09-03 10:50:14 +00:00
|
|
|
|
2022-07-21 11:58:50 +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, nullable=False, default=datetime.now, comment="Created at"
|
|
|
|
)
|
2022-11-29 12:36:46 +00:00
|
|
|
createdBy = Column(ForeignKey("user.id"), nullable=False, index=True, comment="Sender")
|
2022-09-03 10:50:14 +00:00
|
|
|
updatedAt = Column(DateTime, nullable=True, comment="Updated at")
|
2022-11-29 12:36:46 +00:00
|
|
|
updatedBy = Column(ForeignKey("user.id"), nullable=True, index=True, comment="Last Editor")
|
2022-09-03 10:50:14 +00:00
|
|
|
deletedAt = Column(DateTime, nullable=True, comment="Deleted at")
|
2022-11-29 12:36:46 +00:00
|
|
|
deletedBy = Column(ForeignKey("user.id"), nullable=True, index=True, comment="Deleted by")
|
2022-11-30 06:27:12 +00:00
|
|
|
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
|
2022-09-03 10:50:14 +00:00
|
|
|
replyTo = Column(
|
|
|
|
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")
|