diff --git a/files/helpers/get.py b/files/helpers/get.py index 70cd80eb8..5351b20fa 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -113,7 +113,7 @@ def get_account(id, v=None): return user -def get_post(i, v=None, graceful=False, rendered=False): +def get_post(i, v=None, graceful=False, rendered=False, entered=False): try: i = int(i) except: abort(404) @@ -144,13 +144,16 @@ def get_post(i, v=None, graceful=False, rendered=False): ) if rendered: - posts = post.options( + post = post.options( joinedload(Submission.flags), joinedload(Submission.awards), joinedload(Submission.author), joinedload(Submission.options).joinedload(SubmissionOption.votes) ) + if entered: + post = post.options(joinedload(Submission.comments)) + post=post.one_or_none() if not post: diff --git a/files/routes/posts.py b/files/routes/posts.py index 8ba851b7b..01bba4816 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -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, rendered=True) + post = get_post(pid, v=v, rendered=True, entered=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