MarseyWorld/files/classes/award.py

88 lines
2.0 KiB
Python
Raw Normal View History

2021-07-25 00:04:07 +00:00
from sqlalchemy import *
from sqlalchemy.orm import relationship
2021-08-04 15:35:10 +00:00
from files.__main__ import Base
2021-08-22 18:25:50 +00:00
from os import environ
2021-09-19 18:27:00 +00:00
from files.helpers.lazy import lazy
2021-07-25 00:04:07 +00:00
2021-08-22 18:25:50 +00:00
site_name = environ.get("SITE_NAME").strip()
2021-08-22 18:26:19 +00:00
if site_name == "Drama":
2021-08-22 18:25:50 +00:00
AWARDS = {
"ban": {
"kind": "ban",
"title": "One-Day Ban",
2021-09-08 09:00:44 +00:00
"description": "Bans the author for a day.",
2021-08-22 18:25:50 +00:00
"icon": "fas fa-gavel",
2021-09-08 08:37:27 +00:00
"color": "text-danger",
"price": 5000
2021-08-22 18:25:50 +00:00
},
"shit": {
"kind": "shit",
2021-09-08 03:19:52 +00:00
"title": "Shit",
2021-09-08 09:00:44 +00:00
"description": "Makes flies swarm a post.",
2021-08-22 18:25:50 +00:00
"icon": "fas fa-poop",
2021-09-08 08:37:27 +00:00
"color": "text-black-50",
"price": 1000
2021-08-22 20:11:48 +00:00
},
2021-09-20 13:11:10 +00:00
"fireflies": {
"kind": "fireflies",
2021-09-20 13:14:42 +00:00
"title": "Fireflies",
2021-09-08 09:00:44 +00:00
"description": "Puts stars on the post.",
2021-08-22 20:11:48 +00:00
"icon": "fas fa-sparkles",
2021-09-08 08:37:27 +00:00
"color": "text-warning",
"price": 1000
2021-08-22 18:25:50 +00:00
}
}
else:
AWARDS = {
"shit": {
"kind": "shit",
2021-09-20 13:14:42 +00:00
"title": "Shit",
2021-09-08 09:00:44 +00:00
"description": "Makes flies swarm a post.",
2021-08-22 18:25:50 +00:00
"icon": "fas fa-poop",
2021-09-08 08:37:27 +00:00
"color": "text-black-50",
"price": 1000
2021-08-23 17:53:50 +00:00
},
2021-09-20 13:11:10 +00:00
"fireflies": {
"kind": "fireflies",
2021-09-20 13:14:42 +00:00
"title": "Fireflies",
2021-09-08 09:00:44 +00:00
"description": "Puts stars on the post.",
2021-08-23 17:53:50 +00:00
"icon": "fas fa-sparkles",
2021-09-08 08:37:27 +00:00
"color": "text-warning",
"price": 1000
2021-08-22 18:25:50 +00:00
}
2021-07-25 00:04:07 +00:00
}
class AwardRelationship(Base):
__tablename__ = "award_relationships"
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"))
2021-09-23 08:44:26 +00:00
submission_id = Column(Integer, ForeignKey("submissions.id"))
comment_id = Column(Integer, ForeignKey("comments.id"))
2021-10-06 22:38:15 +00:00
kind = Column(String)
2021-07-25 00:04:07 +00:00
2021-09-22 14:51:36 +00:00
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", viewonly=True)
2021-09-17 12:36:39 +00:00
2021-09-22 14:51:36 +00:00
post = relationship("Submission", primaryjoin="AwardRelationship.submission_id==Submission.id", viewonly=True)
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", viewonly=True)
2021-07-25 00:04:07 +00:00
2021-07-27 11:06:43 +00:00
2021-07-25 00:04:07 +00:00
@property
2021-09-19 18:25:40 +00:00
@lazy
2021-07-25 00:04:07 +00:00
def type(self):
return AWARDS[self.kind]
2021-07-27 11:06:43 +00:00
@property
2021-09-19 18:25:40 +00:00
@lazy
2021-07-27 11:06:43 +00:00
def title(self):
return self.type['title']
@property
2021-09-19 18:25:40 +00:00
@lazy
2021-07-27 11:06:43 +00:00
def class_list(self):
return self.type['icon']+' '+self.type['color']