2022-05-04 23:09:46 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from files.__main__ import Base
|
|
|
|
from files.helpers.lazy import lazy
|
|
|
|
from files.helpers.const import *
|
2022-06-24 15:35:55 +00:00
|
|
|
from files.helpers.regex import *
|
2022-05-04 23:09:46 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
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-05-25 17:01:29 +00:00
|
|
|
return f"<Flag(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-05-25 17:01:29 +00:00
|
|
|
return f"<CommentFlag(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)
|