forked from rDrama/rDrama
1
0
Fork 0

Merge branch 'master' into mistletoe

master
kek7198 2021-12-10 23:02:51 -06:00
commit d3ea660f92
4 changed files with 9 additions and 6 deletions

View File

@ -96,6 +96,7 @@ class Submission(Base):
return False
def total_bet_voted(self, v):
if "closed" in self.body.lower(): return True
if v:
for option in self.bet_options:
if option.poll_voted(v): return True

View File

@ -22,16 +22,18 @@ if SITE_NAME == 'PCM': cc = "splash mountain"
else: cc = "country club"
@app.get("/distribute/<cid>")
@admin_level_required(2)
@admin_level_required(3)
def distribute(v, cid):
try: int(cid)
except: abort(400)
post = g.db.query(Comment).filter_by(id=cid).first().post.permalink
votes = g.db.query(CommentVote).filter_by(comment_id=cid)
autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first()
coinsperperson = int(autobetter.coins / votes.count())
for vote in votes:
u = vote.user
u.coins += coinsperperson
send_notification(u.id, f"You won {coinsperperson} coins betting on https://{request.host}{post} !")
g.db.add(u)
autobetter.coins = 0

View File

@ -211,7 +211,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
posts = posts.filter(Submission.created_utc >= cutoff)
else: cutoff = 0
if sort == "new": posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
if sort != "hot": posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
else: posts = posts.filter_by(is_banned=False, stickied=None, private=False, deleted_utc = 0)
if v and v.admin_level == 0:
@ -265,14 +265,14 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
posts = posts[:size]
if sort != "new":
if sort == "hot" and page == 1:
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False)
if v and v.admin_level == 0:
blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()]
blocked = [x[0] for x in g.db.query(UserBlock.user_id).filter_by(target_id=v.id).all()]
pins = pins.filter(Submission.author_id.notin_(blocking), Submission.author_id.notin_(blocked))
if sort != "new" and page == 1 and not gt and not lt: posts = pins.all() + posts
posts = pins.all() + posts
if ids_only: posts = [x.id for x in posts]

View File

@ -902,7 +902,7 @@ def submit_post(v):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
if v and v.admin_level > 1:
if v and v.admin_level > 2:
bet_options = []
for i in re.finditer('\s*\$\$\$([^\$\n]+)\$\$\$\s*', body):
bet_options.append(i.group(1))
@ -970,7 +970,7 @@ def submit_post(v):
g.db.add(new_post)
g.db.flush()
if v and v.admin_level > 1:
if v and v.admin_level > 2:
for option in bet_options:
bet_option = Comment(author_id=AUTOBETTER_ID,
parent_submission=new_post.id,