forked from rDrama/rDrama
1
0
Fork 0

make only house members able to vote on polls in their house hole

master
Aevann1 2022-09-06 00:30:44 +02:00
parent 185fc04101
commit 8085de14e4
3 changed files with 16 additions and 2 deletions

View File

@ -378,7 +378,9 @@ class Comment(Base):
else:
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
if c.voted(v): body += " checked"
if v: body += f''' onchange="poll_vote('{c.id}', 'comment')"'''
if v:
if self.post.sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)): body += ' disabled '
body += f''' onchange="poll_vote('{c.id}', 'comment')"'''
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
body += f'"> - <a href="/votes/comment/option/{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'

View File

@ -382,7 +382,9 @@ class Submission(Base):
else:
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{o.id}" name="option"'
if o.voted(v): body += " checked"
if v: body += f''' onchange="poll_vote('{o.id}', 'post')"'''
if v:
if self.sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)): body += ' disabled '
body += f''' onchange="poll_vote('{o.id}', 'post')"'''
else: body += f''' onchange="poll_vote_no_v('{o.id}', '{self.id}')"'''
body += f'''><label class="custom-control-label" for="{o.id}">{o.body_html}<span class="presult-{self.id}'''
body += f'"> - <a href="/votes/post/option/{o.id}"><span id="poll-{o.id}">{o.upvotes}</span> votes</a></span></label></div>'

View File

@ -16,6 +16,11 @@ def vote_option(option_id, v):
if not option: abort(404)
sub = option.post.sub
if sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)):
return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"}
if option.exclusive == 2:
if v.coins < 200: return {"error": "You don't have 200 coins!"}
v.coins -= 200
@ -77,6 +82,11 @@ def vote_option_comment(option_id, v):
if not option: abort(404)
sub = option.comment.post.sub
if sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)):
return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"}
if option.exclusive:
vote = g.db.query(CommentOptionVote).join(CommentOption).filter(
CommentOptionVote.user_id==v.id,