2022-11-15 09:19:08 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
from sqlalchemy import Column, ForeignKey
|
2022-05-04 23:09:46 +00:00
|
|
|
from sqlalchemy.orm import relationship
|
2022-11-15 09:19:08 +00:00
|
|
|
from sqlalchemy.sql.sqltypes import *
|
|
|
|
|
|
|
|
from files.classes import Base
|
2022-05-04 23:09:46 +00:00
|
|
|
from files.helpers.lazy import lazy
|
2022-11-15 09:19:08 +00:00
|
|
|
from files.helpers.regex import censor_slurs
|
2022-05-04 23:09:46 +00:00
|
|
|
|
|
|
|
class Flag(Base):
|
|
|
|
__tablename__ = "flags"
|
|
|
|
|
|
|
|
post_id = Column(Integer, ForeignKey("submissions.id"), primary_key=True)
|
|
|
|
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
|
|
|
reason = Column(String)
|
2022-09-19 20:40:33 +00:00
|
|
|
created_utc = Column(Integer)
|
2022-05-04 23:09:46 +00:00
|
|
|
|
2022-07-02 06:48:04 +00:00
|
|
|
user = relationship("User", primaryjoin = "Flag.user_id == User.id", uselist = False)
|
2022-05-04 23:09:46 +00:00
|
|
|
|
2022-09-19 20:40:33 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
2022-05-04 23:09:46 +00:00
|
|
|
def __repr__(self):
|
2022-11-29 21:02:38 +00:00
|
|
|
return f"<{self.__class__.__name__}(user_id={self.user_id}, post_id={self.post_id})>"
|
2022-05-04 23:09:46 +00:00
|
|
|
|
|
|
|
@lazy
|
|
|
|
def realreason(self, v):
|
|
|
|
return censor_slurs(self.reason, v)
|
|
|
|
|
|
|
|
|
|
|
|
class CommentFlag(Base):
|
|
|
|
__tablename__ = "commentflags"
|
|
|
|
|
|
|
|
comment_id = Column(Integer, ForeignKey("comments.id"), primary_key=True)
|
|
|
|
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
|
|
|
reason = Column(String)
|
2022-09-19 20:40:33 +00:00
|
|
|
created_utc = Column(Integer)
|
2022-05-04 23:09:46 +00:00
|
|
|
|
2022-07-02 06:48:04 +00:00
|
|
|
user = relationship("User", primaryjoin = "CommentFlag.user_id == User.id", uselist = False)
|
2022-05-04 23:09:46 +00:00
|
|
|
|
2022-09-19 20:40:33 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
2022-05-04 23:09:46 +00:00
|
|
|
def __repr__(self):
|
2022-11-29 21:02:38 +00:00
|
|
|
return f"<{self.__class__.__name__}(user_id={self.user_id}, comment_id={self.comment_id})>"
|
2022-05-04 23:09:46 +00:00
|
|
|
|
|
|
|
@lazy
|
|
|
|
def realreason(self, v):
|
2022-09-29 05:43:29 +00:00
|
|
|
return censor_slurs(self.reason, v)
|