2023-11-22 16:38:39 +00:00
|
|
|
import time
|
2022-09-19 13:50:43 +00:00
|
|
|
from enum import Enum as Enumeration
|
2023-11-22 16:38:39 +00:00
|
|
|
|
2023-12-17 04:59:16 +00:00
|
|
|
from sqlalchemy import Column, ForeignKey, Integer, String
|
2023-11-22 16:38:39 +00:00
|
|
|
|
2025-06-01 23:56:11 +00:00
|
|
|
from services.db import BaseModel as Base
|
2022-09-19 13:50:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ReactionKind(Enumeration):
|
2023-11-27 16:03:47 +00:00
|
|
|
# TYPE = <reaction index> # rating diff
|
|
|
|
|
2025-07-02 19:30:21 +00:00
|
|
|
# editor specials
|
2024-04-17 15:32:23 +00:00
|
|
|
AGREE = "AGREE" # +1
|
|
|
|
DISAGREE = "DISAGREE" # -1
|
2025-07-02 19:30:21 +00:00
|
|
|
|
|
|
|
# coauthor specials
|
|
|
|
ASK = "ASK" # 0
|
|
|
|
PROPOSE = "PROPOSE" # 0
|
|
|
|
|
|
|
|
# generic internal reactions
|
2024-04-17 15:32:23 +00:00
|
|
|
ACCEPT = "ACCEPT" # +1
|
|
|
|
REJECT = "REJECT" # -1
|
2023-11-27 16:03:47 +00:00
|
|
|
|
2025-07-02 19:30:21 +00:00
|
|
|
# experts speacials
|
2024-04-17 15:32:23 +00:00
|
|
|
PROOF = "PROOF" # +1
|
|
|
|
DISPROOF = "DISPROOF" # -1
|
2024-04-09 11:03:50 +00:00
|
|
|
|
2025-07-02 19:30:21 +00:00
|
|
|
# comment and quote
|
|
|
|
QUOTE = "QUOTE" # 0
|
|
|
|
COMMENT = "COMMENT" # 0
|
|
|
|
|
|
|
|
# generic rating
|
2024-04-17 15:32:23 +00:00
|
|
|
LIKE = "LIKE" # +1
|
|
|
|
DISLIKE = "DISLIKE" # -1
|
2022-07-21 11:58:50 +00:00
|
|
|
|
2025-07-02 19:30:21 +00:00
|
|
|
# credit artist or researcher
|
|
|
|
CREDIT = "CREDIT" # +1
|
|
|
|
SILENT = "SILENT" # 0
|
|
|
|
|
|
|
|
|
|
|
|
REACTION_KINDS = ReactionKind.__members__.keys()
|
|
|
|
|
2022-09-03 10:50:14 +00:00
|
|
|
|
2022-07-21 11:58:50 +00:00
|
|
|
class Reaction(Base):
|
2024-04-17 15:32:23 +00:00
|
|
|
__tablename__ = "reaction"
|
2023-10-23 14:47:11 +00:00
|
|
|
|
2024-04-17 15:32:23 +00:00
|
|
|
body = Column(String, default="", comment="Reaction Body")
|
2024-08-06 16:01:50 +00:00
|
|
|
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()), index=True)
|
|
|
|
updated_at = Column(Integer, nullable=True, comment="Updated at", index=True)
|
|
|
|
deleted_at = Column(Integer, nullable=True, comment="Deleted at", index=True)
|
2024-04-17 15:32:23 +00:00
|
|
|
deleted_by = Column(ForeignKey("author.id"), nullable=True)
|
|
|
|
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
|
|
|
|
quote = Column(String, nullable=True, comment="Original quoted text")
|
2024-08-07 14:45:22 +00:00
|
|
|
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
|
2024-04-17 15:32:23 +00:00
|
|
|
created_by = Column(ForeignKey("author.id"), nullable=False)
|
2024-08-06 16:03:43 +00:00
|
|
|
kind = Column(String, nullable=False, index=True)
|
2023-11-22 16:38:39 +00:00
|
|
|
|
|
|
|
oid = Column(String)
|