VIEW MORE
This commit is contained in:
parent
de4a67efee
commit
926e4ae6d5
1 changed files with 33 additions and 8 deletions
|
@ -116,6 +116,7 @@ def post_id(pid, anything=None, v=None):
|
|||
|
||||
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
|
||||
|
||||
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
|
||||
|
||||
if v:
|
||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||
|
@ -134,10 +135,7 @@ def post_id(pid, anything=None, v=None):
|
|||
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
|
||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||
|
||||
comments=comments.filter(
|
||||
Comment.parent_submission == post.id,
|
||||
Comment.author_id != AUTOPOLLER_ID,
|
||||
).join(
|
||||
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None).join(
|
||||
votes,
|
||||
votes.c.comment_id == Comment.id,
|
||||
isouter=True
|
||||
|
@ -162,6 +160,9 @@ def post_id(pid, anything=None, v=None):
|
|||
elif sort == "bottom":
|
||||
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
||||
|
||||
offset = int(request.values.get("offset", 0))
|
||||
if offset: comments = comments.offset(offset)
|
||||
|
||||
output = []
|
||||
for c in comments.all():
|
||||
comment = c[0]
|
||||
|
@ -170,10 +171,19 @@ def post_id(pid, anything=None, v=None):
|
|||
comment.is_blocked = c[3] or 0
|
||||
output.append(comment)
|
||||
|
||||
post.replies = [x for x in output if x.is_pinned] + [x for x in output if x.level == 1 and not x.is_pinned]
|
||||
comments = []
|
||||
count = 0
|
||||
for comment in output:
|
||||
comments.append(comment)
|
||||
count += g.db.query(Comment.id).filter_by(top_comment_id=comment.id).count()
|
||||
offset += 1
|
||||
if count > 3: break
|
||||
|
||||
if len(output) == len(comments): offset = None
|
||||
|
||||
post.replies = pinned + comments
|
||||
else:
|
||||
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID)
|
||||
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
|
||||
|
||||
if sort == "new":
|
||||
comments = comments.order_by(Comment.created_utc.desc())
|
||||
|
@ -186,8 +196,23 @@ def post_id(pid, anything=None, v=None):
|
|||
elif sort == "bottom":
|
||||
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
||||
|
||||
post.replies = comments.filter(Comment.is_pinned != None).all() + comments.filter(Comment.level == 1, Comment.is_pinned == None).all()
|
||||
offset = int(request.values.get("offset", 0))
|
||||
if offset: comments = comments.offset(offset)
|
||||
|
||||
comments = comments.all()
|
||||
|
||||
comments2 = []
|
||||
count = 0
|
||||
for comment in comments:
|
||||
comments2.append(comment)
|
||||
count += g.db.query(Comment.id).filter_by(top_comment_id=comment.id).count()
|
||||
offset += 1
|
||||
if count > 3: break
|
||||
|
||||
if len(comments) == len(comments2): offset = None
|
||||
|
||||
post.replies = pinned + comments2
|
||||
|
||||
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD] and not request.values.get("sort"): post.replies = post.replies[:10]
|
||||
|
||||
post.views += 1
|
||||
|
@ -202,7 +227,7 @@ def post_id(pid, anything=None, v=None):
|
|||
else:
|
||||
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
|
||||
else: template = "submission.html"
|
||||
return render_template(template, v=v, p=post, sort=sort, render_replies=True)
|
||||
return render_template(template, v=v, p=post, sort=sort, render_replies=True, offset=offset)
|
||||
|
||||
|
||||
@app.post("/edit_post/<pid>")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue