more testing

remotes/1693045480750635534/spooky-22
Aevann1 2022-07-01 15:34:11 +02:00
parent a917537c5f
commit e8f5827c5e
5 changed files with 9 additions and 6 deletions

View File

@ -113,7 +113,7 @@ def get_account(id, v=None):
return user
def get_post(i, v=None, graceful=False):
def get_post(i, v=None, graceful=False, rendered=False):
if not i:
if graceful: return None
@ -140,6 +140,9 @@ def get_post(i, v=None, graceful=False):
isouter=True
)
if rendered:
posts = post.options(joinedload(Submission.flags), joinedload(Submission.awards))
post=post.one_or_none()
if not post:

View File

@ -11,7 +11,7 @@ def post_embed(id, v):
try: id = int(id)
except: return None
p = get_post(id, v, graceful=True)
p = get_post(id, v, graceful=True, rendered=True)
if p: return render_template("submission_listing.html", listing=[p], v=v)
return ''

View File

@ -106,7 +106,7 @@ def buy(v, award):
@is_not_permabanned
def award_thing(v, thing_type, id):
if thing_type == 'post': thing = get_post(id)
if thing_type == 'post': thing = get_post(id, rendered=True)
else: thing = get_comment(id)
if not thing: return {"error": f"That {thing_type} doesn't exist."}, 404

View File

@ -64,7 +64,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
try: pid = int(pid)
except: abort(404)
post = get_post(pid, v=v)
post = get_post(pid, v=v, rendered=True)
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
if request.headers.get("Authorization"): return {'error': 'This content is not suitable for some users and situations.'}

View File

@ -128,7 +128,7 @@ def post_id(pid, anything=None, v=None, sub=None):
try: pid = int(pid)
except: abort(404)
post = get_post(pid, v=v)
post = get_post(pid, v=v, rendered=True)
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"Must be 18+ to view"}, 451
@ -393,7 +393,7 @@ def morecomments(v, cid):
@limiter.limit("1/second;10/minute;100/hour;200/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')
@auth_required
def edit_post(pid, v):
p = get_post(pid)
p = get_post(pid, rendered=True)
title = request.values.get("title", "").strip().replace('','')