Merge branch 'mistletoe' of https://github.com/Aevann1/Drama into mistletoe
This commit is contained in:
commit
cd6c893d36
7 changed files with 63 additions and 13 deletions
|
@ -281,9 +281,15 @@ class User(Base):
|
||||||
if not self.is_suspended: return None
|
if not self.is_suspended: return None
|
||||||
return g.db.query(User).filter_by(id=self.is_banned).first()
|
return g.db.query(User).filter_by(id=self.is_banned).first()
|
||||||
|
|
||||||
|
@lazy
|
||||||
def has_badge(self, badge_id):
|
def has_badge(self, badge_id):
|
||||||
return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).first()
|
return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).first()
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def grinch(self):
|
||||||
|
return self.has_badge(91)
|
||||||
|
|
||||||
def hash_password(self, password):
|
def hash_password(self, password):
|
||||||
return generate_password_hash(
|
return generate_password_hash(
|
||||||
password, method='pbkdf2:sha512', salt_length=8)
|
password, method='pbkdf2:sha512', salt_length=8)
|
||||||
|
@ -418,6 +424,7 @@ class User(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def profile_url(self):
|
def profile_url(self):
|
||||||
|
if self.grinch: return f"https://{site}/assets/images/grinch.webp?v=1"
|
||||||
if self.agendaposter: return f"https://{site}/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?v=1"
|
if self.agendaposter: return f"https://{site}/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?v=1"
|
||||||
if self.profileurl: return self.profileurl
|
if self.profileurl: return self.profileurl
|
||||||
if "rama" in site: return f"https://{site}/assets/images/defaultpictures/{random.randint(1, 150)}.webp?v=1"
|
if "rama" in site: return f"https://{site}/assets/images/defaultpictures/{random.randint(1, 150)}.webp?v=1"
|
||||||
|
|
|
@ -456,6 +456,14 @@ AWARDS = {
|
||||||
"color": "",
|
"color": "",
|
||||||
"price": 1000
|
"price": 1000
|
||||||
},
|
},
|
||||||
|
"grinch": {
|
||||||
|
"kind": "grinch",
|
||||||
|
"title": "Grinch",
|
||||||
|
"description": "???",
|
||||||
|
"icon": "fas fa-angry",
|
||||||
|
"color": "text-green-500",
|
||||||
|
"price": 1000
|
||||||
|
},
|
||||||
"haunt": {
|
"haunt": {
|
||||||
"kind": "haunt",
|
"kind": "haunt",
|
||||||
"title": "Haunt",
|
"title": "Haunt",
|
||||||
|
@ -716,6 +724,14 @@ AWARDS2 = {
|
||||||
"color": "",
|
"color": "",
|
||||||
"price": 1000
|
"price": 1000
|
||||||
},
|
},
|
||||||
|
"grinch": {
|
||||||
|
"kind": "grinch",
|
||||||
|
"title": "Grinch",
|
||||||
|
"description": "???",
|
||||||
|
"icon": "fas fa-angry",
|
||||||
|
"color": "text-green-500",
|
||||||
|
"price": 1000
|
||||||
|
},
|
||||||
"shit": {
|
"shit": {
|
||||||
"kind": "shit",
|
"kind": "shit",
|
||||||
"title": "Shit",
|
"title": "Shit",
|
||||||
|
|
|
@ -883,7 +883,7 @@ def ban_post(post_id, v):
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
|
|
||||||
v.coins += 1
|
v.coins += 2
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -917,7 +917,7 @@ def unban_post(post_id, v):
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
|
|
||||||
v.coins -= 1
|
v.coins -= 2
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
|
@ -102,6 +102,15 @@ def shop(v):
|
||||||
"owned": 0,
|
"owned": 0,
|
||||||
"price": 1000
|
"price": 1000
|
||||||
},
|
},
|
||||||
|
"grinch": {
|
||||||
|
"kind": "grinch",
|
||||||
|
"title": "Grinch",
|
||||||
|
"description": "???",
|
||||||
|
"icon": "fas fa-angry",
|
||||||
|
"color": "text-green-500",
|
||||||
|
"owned": 0,
|
||||||
|
"price": 1000
|
||||||
|
},
|
||||||
"shit": {
|
"shit": {
|
||||||
"kind": "shit",
|
"kind": "shit",
|
||||||
"title": "Shit",
|
"title": "Shit",
|
||||||
|
@ -348,6 +357,14 @@ def buy(v, award):
|
||||||
"color": "",
|
"color": "",
|
||||||
"price": 1000
|
"price": 1000
|
||||||
},
|
},
|
||||||
|
"grinch": {
|
||||||
|
"kind": "grinch",
|
||||||
|
"title": "Grinch",
|
||||||
|
"description": "???",
|
||||||
|
"icon": "fas fa-angry",
|
||||||
|
"color": "text-green-500",
|
||||||
|
"price": 1000
|
||||||
|
},
|
||||||
"shit": {
|
"shit": {
|
||||||
"kind": "shit",
|
"kind": "shit",
|
||||||
"title": "Shit",
|
"title": "Shit",
|
||||||
|
@ -718,6 +735,11 @@ def award_post(pid, v):
|
||||||
if not author.has_badge(90):
|
if not author.has_badge(90):
|
||||||
new_badge = Badge(badge_id=90, user_id=author.id)
|
new_badge = Badge(badge_id=90, user_id=author.id)
|
||||||
g.db.add(new_badge)
|
g.db.add(new_badge)
|
||||||
|
elif kind == "grinch":
|
||||||
|
send_notification(CARP_ID, f"@{v.username} used {kind} award!")
|
||||||
|
if not author.has_badge(91):
|
||||||
|
new_badge = Badge(badge_id=91, user_id=author.id)
|
||||||
|
g.db.add(new_badge)
|
||||||
|
|
||||||
if post.author.received_award_count: post.author.received_award_count += 1
|
if post.author.received_award_count: post.author.received_award_count += 1
|
||||||
else: post.author.received_award_count = 1
|
else: post.author.received_award_count = 1
|
||||||
|
@ -880,6 +902,11 @@ def award_comment(cid, v):
|
||||||
if not author.has_badge(90):
|
if not author.has_badge(90):
|
||||||
new_badge = Badge(badge_id=90, user_id=author.id)
|
new_badge = Badge(badge_id=90, user_id=author.id)
|
||||||
g.db.add(new_badge)
|
g.db.add(new_badge)
|
||||||
|
elif kind == "grinch":
|
||||||
|
send_notification(CARP_ID, f"@{v.username} used {kind} award!")
|
||||||
|
if not author.has_badge(91):
|
||||||
|
new_badge = Badge(badge_id=91, user_id=author.id)
|
||||||
|
g.db.add(new_badge)
|
||||||
|
|
||||||
if c.author.received_award_count: c.author.received_award_count += 1
|
if c.author.received_award_count: c.author.received_award_count += 1
|
||||||
else: c.author.received_award_count = 1
|
else: c.author.received_award_count = 1
|
||||||
|
|
|
@ -407,7 +407,7 @@ def api_comment(v):
|
||||||
if v.id == PIZZA_SHILL_ID:
|
if v.id == PIZZA_SHILL_ID:
|
||||||
cratvote = CommentVote(user_id=TAX_RECEIVER_ID, comment_id=c.id, vote_type=1)
|
cratvote = CommentVote(user_id=TAX_RECEIVER_ID, comment_id=c.id, vote_type=1)
|
||||||
g.db.add(cratvote)
|
g.db.add(cratvote)
|
||||||
v.coins += 1
|
v.coins += 2
|
||||||
v.truecoins += 1
|
v.truecoins += 1
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
c.upvotes += 1
|
c.upvotes += 1
|
||||||
|
@ -433,7 +433,7 @@ def api_comment(v):
|
||||||
|
|
||||||
longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ID).first()
|
longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ID).first()
|
||||||
longpostbot.comment_count += 1
|
longpostbot.comment_count += 1
|
||||||
longpostbot.coins += 1
|
longpostbot.coins += 2
|
||||||
g.db.add(longpostbot)
|
g.db.add(longpostbot)
|
||||||
|
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ def submit_post(v):
|
||||||
|
|
||||||
snappy = g.db.query(User).filter_by(id = SNAPPY_ID).first()
|
snappy = g.db.query(User).filter_by(id = SNAPPY_ID).first()
|
||||||
snappy.comment_count += 1
|
snappy.comment_count += 1
|
||||||
snappy.coins += 1
|
snappy.coins += 2
|
||||||
g.db.add(snappy)
|
g.db.add(snappy)
|
||||||
|
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
|
@ -69,7 +69,7 @@ def admin_vote_info_get(v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def api_vote_post(post_id, new, v):
|
def api_vote_post(post_id, new, v):
|
||||||
|
|
||||||
if v.is_banned and not v.unban_utc: return {"error": "forbidden."}, 403
|
if v.is_banned and not v.unban_utc or new == "-1": return {"error": "forbidden."}, 403
|
||||||
|
|
||||||
if new not in ["-1", "0", "1"]: abort(400)
|
if new not in ["-1", "0", "1"]: abort(400)
|
||||||
|
|
||||||
|
@ -85,13 +85,13 @@ def api_vote_post(post_id, new, v):
|
||||||
|
|
||||||
if existing:
|
if existing:
|
||||||
if existing.vote_type == 0 and new != 0:
|
if existing.vote_type == 0 and new != 0:
|
||||||
post.author.coins += 1
|
post.author.coins += 2
|
||||||
post.author.truecoins += 1
|
post.author.truecoins += 1
|
||||||
g.db.add(post.author)
|
g.db.add(post.author)
|
||||||
existing.vote_type = new
|
existing.vote_type = new
|
||||||
g.db.add(existing)
|
g.db.add(existing)
|
||||||
elif existing.vote_type != 0 and new == 0:
|
elif existing.vote_type != 0 and new == 0:
|
||||||
post.author.coins -= 1
|
post.author.coins -= 2
|
||||||
post.author.truecoins -= 1
|
post.author.truecoins -= 1
|
||||||
g.db.add(post.author)
|
g.db.add(post.author)
|
||||||
g.db.delete(existing)
|
g.db.delete(existing)
|
||||||
|
@ -99,7 +99,7 @@ def api_vote_post(post_id, new, v):
|
||||||
existing.vote_type = new
|
existing.vote_type = new
|
||||||
g.db.add(existing)
|
g.db.add(existing)
|
||||||
elif new != 0:
|
elif new != 0:
|
||||||
post.author.coins += 1
|
post.author.coins += 2
|
||||||
post.author.truecoins += 1
|
post.author.truecoins += 1
|
||||||
g.db.add(post.author)
|
g.db.add(post.author)
|
||||||
real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned
|
real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned
|
||||||
|
@ -132,7 +132,7 @@ def api_vote_post(post_id, new, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def api_vote_comment(comment_id, new, v):
|
def api_vote_comment(comment_id, new, v):
|
||||||
|
|
||||||
if v.is_banned and not v.unban_utc: return {"error": "forbidden."}, 403
|
if v.is_banned and not v.unban_utc or new == "-1": return {"error": "forbidden."}, 403
|
||||||
|
|
||||||
if new not in ["-1", "0", "1"]: abort(400)
|
if new not in ["-1", "0", "1"]: abort(400)
|
||||||
|
|
||||||
|
@ -153,13 +153,13 @@ def api_vote_comment(comment_id, new, v):
|
||||||
|
|
||||||
if existing:
|
if existing:
|
||||||
if existing.vote_type == 0 and new != 0:
|
if existing.vote_type == 0 and new != 0:
|
||||||
comment.author.coins += 1
|
comment.author.coins += 2
|
||||||
comment.author.truecoins += 1
|
comment.author.truecoins += 1
|
||||||
g.db.add(comment.author)
|
g.db.add(comment.author)
|
||||||
existing.vote_type = new
|
existing.vote_type = new
|
||||||
g.db.add(existing)
|
g.db.add(existing)
|
||||||
elif existing.vote_type != 0 and new == 0:
|
elif existing.vote_type != 0 and new == 0:
|
||||||
comment.author.coins -= 1
|
comment.author.coins -= 2
|
||||||
comment.author.truecoins -= 1
|
comment.author.truecoins -= 1
|
||||||
g.db.add(comment.author)
|
g.db.add(comment.author)
|
||||||
g.db.delete(existing)
|
g.db.delete(existing)
|
||||||
|
@ -167,7 +167,7 @@ def api_vote_comment(comment_id, new, v):
|
||||||
existing.vote_type = new
|
existing.vote_type = new
|
||||||
g.db.add(existing)
|
g.db.add(existing)
|
||||||
elif new != 0:
|
elif new != 0:
|
||||||
comment.author.coins += 1
|
comment.author.coins += 2
|
||||||
comment.author.truecoins += 1
|
comment.author.truecoins += 1
|
||||||
g.db.add(comment.author)
|
g.db.add(comment.author)
|
||||||
real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned
|
real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue