2021-07-25 00:04:07 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship
|
2021-07-30 15:42:01 +00:00
|
|
|
from drama.__main__ import Base
|
2021-07-25 00:04:07 +00:00
|
|
|
|
|
|
|
AWARDS = {
|
|
|
|
"ban": {
|
2021-07-27 11:06:43 +00:00
|
|
|
"kind": "ban",
|
2021-07-25 00:04:07 +00:00
|
|
|
"title": "1-Day Ban",
|
|
|
|
"description": "Ban the author for a day.",
|
|
|
|
"icon": "fas fa-gavel",
|
|
|
|
"color": "text-danger"
|
|
|
|
},
|
|
|
|
"shit": {
|
2021-07-27 11:06:43 +00:00
|
|
|
"kind": "shit",
|
2021-07-25 00:04:07 +00:00
|
|
|
"title": "Literal Shitpost",
|
2021-07-27 23:16:21 +00:00
|
|
|
"description": "Let OP know how much their post sucks ass. Flies will swarm their idiotic post. (flies only work on posts lol!!)",
|
2021-07-25 00:04:07 +00:00
|
|
|
"icon": "fas fa-poop",
|
|
|
|
"color": "text-black-50"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class AwardRelationship(Base):
|
|
|
|
|
|
|
|
__tablename__ = "award_relationships"
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
|
|
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
2021-07-27 11:06:43 +00:00
|
|
|
submission_id = Column(Integer, ForeignKey("submissions.id"), default=None)
|
|
|
|
comment_id = Column(Integer, ForeignKey("comments.id"), default=None)
|
2021-07-25 00:04:07 +00:00
|
|
|
kind = Column(String(20))
|
|
|
|
|
|
|
|
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", lazy="joined")
|
|
|
|
post = relationship(
|
|
|
|
"Submission",
|
|
|
|
primaryjoin="AwardRelationship.submission_id==Submission.id",
|
|
|
|
lazy="joined"
|
|
|
|
)
|
|
|
|
comment = relationship(
|
|
|
|
"Comment",
|
|
|
|
primaryjoin="AwardRelationship.comment_id==Comment.id",
|
|
|
|
lazy="joined"
|
|
|
|
)
|
|
|
|
|
2021-07-27 11:06:43 +00:00
|
|
|
@property
|
|
|
|
def given(self):
|
|
|
|
return bool(self.submission_id) or bool(self.comment_id)
|
|
|
|
|
2021-07-25 00:04:07 +00:00
|
|
|
@property
|
|
|
|
def type(self):
|
|
|
|
return AWARDS[self.kind]
|
2021-07-27 11:06:43 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def title(self):
|
|
|
|
return self.type['title']
|
|
|
|
|
|
|
|
@property
|
|
|
|
def class_list(self):
|
|
|
|
return self.type['icon']+' '+self.type['color']
|