From d82f1161cfb3b6dd7e3628faad19b70c17df0112 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 5 May 2023 08:38:08 +0300 Subject: [PATCH] use new pagination system in removed posts and comments --- files/routes/admin.py | 28 +++++++++++++++--------- files/templates/admin/removed_posts.html | 19 +--------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index aefa597c0..fbb368ec9 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -734,12 +734,15 @@ def admin_delink_relink_alt(v:User, username, other): @admin_level_required(PERMS['POST_COMMENT_MODERATION']) def admin_removed(v): page = get_page() - ids = g.db.query(Submission.id).join(Submission.author).filter(or_(Submission.is_banned==True, User.shadowbanned != None)).order_by(Submission.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all() - ids=[x[0] for x in ids] - next_exists = len(ids) > PAGE_SIZE - ids = ids[:PAGE_SIZE] - posts = get_posts(ids, v=v) + listing = g.db.query(Submission).options(load_only(Submission.id)).join(Submission.author).filter( + or_(Submission.is_banned==True, User.shadowbanned != None)) + + next_exists = listing.count() + listing = listing.order_by(Submission.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all() + listing = [x.id for x in listing] + + posts = get_posts(listing, v=v) return render_template("admin/removed_posts.html", v=v, @@ -756,11 +759,15 @@ def admin_removed(v): def admin_removed_comments(v): page = get_page() - ids = g.db.query(Comment.id).join(Comment.author).filter(or_(Comment.is_banned==True, User.shadowbanned != None)).order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all() - ids=[x[0] for x in ids] - next_exists = len(ids) > PAGE_SIZE - ids = ids[:PAGE_SIZE] - comments = get_comments(ids, v=v) + listing = g.db.query(Comment).options(load_only(Comment.id)).join(Comment.author).filter( + or_(Comment.is_banned==True, User.shadowbanned != None)) + + next_exists = listing.count() + listing = listing.order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all() + listing = [x.id for x in listing] + + comments = get_comments(listing, v=v) + return render_template("admin/removed_comments.html", v=v, listing=comments, @@ -768,6 +775,7 @@ def admin_removed_comments(v): next_exists=next_exists ) + @app.post("/unchud_user/") @limiter.limit('1/second', scope=rpath) @limiter.limit('1/second', scope=rpath, key_func=get_ID) diff --git a/files/templates/admin/removed_posts.html b/files/templates/admin/removed_posts.html index b52a2a6f1..bc644c956 100644 --- a/files/templates/admin/removed_posts.html +++ b/files/templates/admin/removed_posts.html @@ -28,22 +28,5 @@ {% endblock %} {% block pagenav %} - +{% include "pagination.html" %} {% endblock %}