Make betting polls respect can_gamble.

master
Snakes 2022-05-30 08:13:11 -04:00
parent e32a4bda48
commit 04a878a8c4
3 changed files with 3 additions and 2 deletions

View File

@ -414,7 +414,7 @@ class Submission(Base):
for c in self.bet_options: for c in self.bet_options:
body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"''' body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"'''
if c.poll_voted(v): body += " checked " if c.poll_voted(v): body += " checked "
if not (v and v.coins > 200) or self.total_bet_voted(v): body += " disabled " if not (v and v.coins > 200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled "
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>''' body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>'''
if not self.total_bet_voted(v): if not self.total_bet_voted(v):
body += '''<span class="cost"> (cost of entry: 200 coins)</span>''' body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''

View File

@ -235,6 +235,7 @@ def api_vote_poll(comment_id, v):
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}') @limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')
@is_not_permabanned @is_not_permabanned
def bet(comment_id, v): def bet(comment_id, v):
if not v.can_gamble: return {"error": "You have gambling disabled!"}
if v.coins < 200: return {"error": "You don't have 200 coins!"} if v.coins < 200: return {"error": "You don't have 200 coins!"}

View File

@ -156,7 +156,7 @@
<input autocomplete="off" type="checkbox" class="custom-control-input" id="can_gamble" name="can_gamble"{% if v.can_gamble %} checked{% endif %} onchange="post_toast(this,'/settings/profile?can_gamble='+document.getElementById('can_gamble').checked);"> <input autocomplete="off" type="checkbox" class="custom-control-input" id="can_gamble" name="can_gamble"{% if v.can_gamble %} checked{% endif %} onchange="post_toast(this,'/settings/profile?can_gamble='+document.getElementById('can_gamble').checked);">
<label class="custom-control-label" for="can_gamble"></label> <label class="custom-control-label" for="can_gamble"></label>
</div> </div>
<span class="text-small-extra text-muted">Disable to prevent use of blackjack, slots, treasure chests, and the lottery.</span> <span class="text-small-extra text-muted">Disable to prevent use of blackjack, slots, treasure chests, the lottery, and betting polls.</span>
</div> </div>
</div> </div>
</div> </div>