don't duplicate get checks for posts
parent
d0a19d5cc3
commit
057bc360bf
|
@ -8,10 +8,6 @@ from files.helpers.assetcache import assetcache_path
|
|||
|
||||
@app.template_filter("post_embed")
|
||||
def post_embed(id, v):
|
||||
|
||||
try: id = int(id)
|
||||
except: return None
|
||||
|
||||
p = get_post(id, v, graceful=True)
|
||||
|
||||
if p: return render_template("submission_listing.html", listing=[p], v=v)
|
||||
|
|
|
@ -1121,12 +1121,7 @@ def mute_user(v, user_id, mute_status):
|
|||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@admin_level_required(2)
|
||||
def remove_post(post_id, v):
|
||||
|
||||
post = get_post(post_id)
|
||||
|
||||
if not post:
|
||||
abort(400)
|
||||
|
||||
post.is_banned = True
|
||||
post.is_approved = None
|
||||
post.stickied = None
|
||||
|
@ -1164,9 +1159,6 @@ def approve_post(post_id, v):
|
|||
if post.author.id == v.id and post.author.agendaposter and AGENDAPOSTER_PHRASE not in post.body.lower() and post.sub != 'chudrama':
|
||||
return {"error": "You can't bypass the chud award!"}, 400
|
||||
|
||||
if not post:
|
||||
abort(400)
|
||||
|
||||
if post.is_banned:
|
||||
ma=ModAction(
|
||||
kind="unban_post",
|
||||
|
@ -1192,11 +1184,8 @@ def approve_post(post_id, v):
|
|||
@app.post("/distinguish/<post_id>")
|
||||
@admin_level_required(1)
|
||||
def distinguish_post(post_id, v):
|
||||
|
||||
post = get_post(post_id)
|
||||
|
||||
if not post: abort(404)
|
||||
|
||||
if post.author_id != v.id and v.admin_level < 2 : abort(403)
|
||||
|
||||
if post.distinguish_level:
|
||||
|
@ -1227,7 +1216,7 @@ def sticky_post(post_id, v):
|
|||
abort(403)
|
||||
|
||||
post = get_post(post_id)
|
||||
if post and not post.stickied:
|
||||
if not post.stickied:
|
||||
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count()
|
||||
if pins >= PIN_LIMIT:
|
||||
if v.admin_level > 2:
|
||||
|
@ -1255,7 +1244,7 @@ def sticky_post(post_id, v):
|
|||
def unsticky_post(post_id, v):
|
||||
|
||||
post = get_post(post_id)
|
||||
if post and post.stickied:
|
||||
if post.stickied:
|
||||
if post.stickied.endswith('(pin award)'): return {"error": "Can't unpin award pins!"}, 403
|
||||
|
||||
post.stickied = None
|
||||
|
|
|
@ -133,8 +133,6 @@ def award_thing(v, thing_type, id):
|
|||
if thing_type == 'post': thing = get_post(id)
|
||||
else: thing = get_comment(id)
|
||||
|
||||
if not thing: return {"error": f"This {thing_type} doesn't exist."}, 404
|
||||
|
||||
if v.shadowbanned: return render_template('errors/500.html', err=True, v=v), 500
|
||||
|
||||
kind = request.values.get("kind", "").strip()
|
||||
|
@ -165,7 +163,7 @@ def award_thing(v, thing_type, id):
|
|||
note = request.values.get("note", "").strip()
|
||||
|
||||
author = thing.author
|
||||
if author.shadowbanned: return {"error": f"This {thing_type} doesn't exist."}, 404
|
||||
if author.shadowbanned: abort(404)
|
||||
|
||||
if SITE == 'rdrama.net' and author.id in (PIZZASHILL_ID, CARP_ID):
|
||||
return {"error": "This user is immune to awards."}, 403
|
||||
|
|
|
@ -234,8 +234,6 @@ def post_id(pid, anything=None, v=None, sub=None):
|
|||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@auth_desired_with_logingate
|
||||
def viewmore(v, pid, sort, offset):
|
||||
try: pid = int(pid)
|
||||
except: abort(400)
|
||||
post = get_post(pid, v=v)
|
||||
if post.club and not (v and (v.paid_dues or v.id == post.author_id)): abort(403)
|
||||
|
||||
|
|
Loading…
Reference in New Issue