Add page for filtered comments

This commit is contained in:
Julian Rota 2022-06-27 23:53:17 -04:00 committed by Ben Rog-Wilhelm
parent 4ecb4747c1
commit 4b0c4fcc73
4 changed files with 61 additions and 3 deletions

View file

@ -450,7 +450,7 @@ def shadowbanned(v):
users = [x for x in g.db.query(User).filter(User.shadowbanned != None).order_by(User.shadowbanned).all()]
return render_template("shadowbanned.html", v=v, users=users)
@app.get("/admin/filtered_submissions")
@app.get("/admin/filtered/posts")
@admin_level_required(2)
def filtered_submissions(v):
try: page = int(request.values.get('page', 1))
@ -469,6 +469,25 @@ def filtered_submissions(v):
return render_template("admin/filtered_submissions.html", v=v, listing=posts, next_exists=next_exists, page=page, sort="new")
@app.get("/admin/filtered/comments")
@admin_level_required(2)
def filtered_comments(v):
try: page = int(request.values.get('page', 1))
except: page = 1
comments_just_ids = g.db.query(Comment) \
.order_by(Comment.id.desc()) \
.filter(Comment.filter_state == 'filtered') \
.limit(26) \
.offset(25 * (page - 1)) \
.with_entities(Comment.id)
comment_ids = [x.id for x in comments_just_ids]
next_exists = (len(comment_ids) > 25)
comments = get_comments(comment_ids[:25], v=v)
return render_template("admin/filtered_comments.html", v=v, listing=comments, next_exists=next_exists, page=page, sort="new")
@app.post("/admin/update_filter_status")
@admin_level_required(2)
def update_filter_status(v):