forked from MarseyWorld/MarseyWorld
make it so only the post author can declare winner and not all admins
parent
25be392e3b
commit
9e1425d93e
|
@ -301,7 +301,7 @@ class Submission(Base):
|
||||||
if o.exclusive == 3:
|
if o.exclusive == 3:
|
||||||
body += " - <b>WINNER!</b>"
|
body += " - <b>WINNER!</b>"
|
||||||
|
|
||||||
if not winner and v and v.admin_level >= PERMS['POST_BETS_DISTRIBUTE']:
|
if not winner and v and v.id == self.author_id:
|
||||||
body += f'''<button class="btn btn-primary distribute" data-click2="postToastReload(this,'/distribute/{o.id}')" onclick="areyousure(this)">Declare winner</button>'''
|
body += f'''<button class="btn btn-primary distribute" data-click2="postToastReload(this,'/distribute/{o.id}')" onclick="areyousure(this)">Declare winner</button>'''
|
||||||
body += "</div>"
|
body += "</div>"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -249,7 +249,6 @@ PERMS = { # Minimum admin_level to perform action.
|
||||||
'POST_TO_CHANGELOG': 1, # note: code contributors can also post to changelog
|
'POST_TO_CHANGELOG': 1, # note: code contributors can also post to changelog
|
||||||
'POST_TO_POLL_THREAD': 2,
|
'POST_TO_POLL_THREAD': 2,
|
||||||
'POST_BETS': 3,
|
'POST_BETS': 3,
|
||||||
'POST_BETS_DISTRIBUTE': 3, # probably should be the same as POST_BETS but w/e
|
|
||||||
'VIEW_PENDING_SUBMITTED_MARSEYS': 3,
|
'VIEW_PENDING_SUBMITTED_MARSEYS': 3,
|
||||||
'VIEW_PENDING_SUBMITTED_HATS': 3,
|
'VIEW_PENDING_SUBMITTED_HATS': 3,
|
||||||
'MODERATE_PENDING_SUBMITTED_MARSEYS': 3, # note: there is an extra check so that only """carp""" can approve them
|
'MODERATE_PENDING_SUBMITTED_MARSEYS': 3, # note: there is an extra check so that only """carp""" can approve them
|
||||||
|
|
|
@ -191,7 +191,7 @@ def remove_admin(v, username):
|
||||||
|
|
||||||
@app.post("/distribute/<option_id>")
|
@app.post("/distribute/<option_id>")
|
||||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||||
@admin_level_required(PERMS['POST_BETS_DISTRIBUTE'])
|
@auth_required
|
||||||
def distribute(v, option_id):
|
def distribute(v, option_id):
|
||||||
autojanny = get_account(AUTOJANNY_ID)
|
autojanny = get_account(AUTOJANNY_ID)
|
||||||
if autojanny.coins == 0: abort(400, "@AutoJanny has 0 coins")
|
if autojanny.coins == 0: abort(400, "@AutoJanny has 0 coins")
|
||||||
|
@ -209,6 +209,9 @@ def distribute(v, option_id):
|
||||||
|
|
||||||
post = option.post
|
post = option.post
|
||||||
|
|
||||||
|
if v.id != post.author_id:
|
||||||
|
abort(403, "Only the post author can declare the winning bet!")
|
||||||
|
|
||||||
pool = 0
|
pool = 0
|
||||||
for o in post.options:
|
for o in post.options:
|
||||||
if o.exclusive >= 2: pool += o.upvotes
|
if o.exclusive >= 2: pool += o.upvotes
|
||||||
|
|
Loading…
Reference in New Issue