2021-07-21 01:12:26 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship
|
2021-08-04 15:35:10 +00:00
|
|
|
from files.__main__ import Base
|
2021-09-19 18:25:40 +00:00
|
|
|
from files.helpers.lazy import lazy
|
2021-09-19 18:28:31 +00:00
|
|
|
import time
|
2021-07-21 01:12:26 +00:00
|
|
|
|
2021-09-19 18:22:57 +00:00
|
|
|
class Flag(Base):
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
__tablename__ = "flags"
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
post_id = Column(Integer, ForeignKey("submissions.id"))
|
|
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
2021-07-25 23:49:53 +00:00
|
|
|
reason = Column(String(100))
|
2021-07-21 01:12:26 +00:00
|
|
|
|
2021-09-17 12:36:39 +00:00
|
|
|
user = relationship("User", lazy = "joined", primaryjoin = "Flag.user_id == User.id", uselist = False, viewonly=True)
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
|
|
|
return f"<Flag(id={self.id})>"
|
|
|
|
|
2021-09-19 18:22:57 +00:00
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def created_date(self):
|
|
|
|
return time.strftime("%d %B %Y", time.gmtime(self.created_utc))
|
2021-07-21 01:12:26 +00:00
|
|
|
|
2021-09-19 18:22:57 +00:00
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def created_datetime(self):
|
|
|
|
return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc)))
|
|
|
|
|
|
|
|
|
|
|
|
class CommentFlag(Base):
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
__tablename__ = "commentflags"
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
|
|
comment_id = Column(Integer, ForeignKey("comments.id"))
|
2021-07-25 23:49:53 +00:00
|
|
|
reason = Column(String(100))
|
2021-07-21 01:12:26 +00:00
|
|
|
|
2021-09-17 12:36:39 +00:00
|
|
|
user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False, viewonly=True)
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
|
|
|
return f"<CommentFlag(id={self.id})>"
|
2021-09-19 18:22:57 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def created_date(self):
|
|
|
|
return time.strftime("%d %B %Y", time.gmtime(self.created_utc))
|
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def created_datetime(self):
|
|
|
|
return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc)))
|