master
Aevann1 2021-08-14 23:52:18 +02:00
parent 7fa33403b4
commit e020f9e82a
1 changed files with 36 additions and 25 deletions

View File

@ -37,24 +37,6 @@ def agendaposters(v):
return render_template("banned.html", v=v, users=users)
@app.get("/admin/flagged/posts")
@admin_level_required(3)
def flagged_posts(v):
page = max(1, int(request.args.get("page", 1)))
posts = g.db.query(Submission).filter_by(is_approved=0, is_banned=False).order_by(Submission.id.desc())
posts = [p for p in posts if p.active_flags > 0]
firstrange = 25 * (page - 1)
secondrange = firstrange+26
posts = posts[firstrange:secondrange]
next_exists = (len(posts) == 26)
return render_template("admin/flagged_posts.html",
next_exists=next_exists, listing=posts[:25], page=page, v=v)
@app.get("/admin/image_posts")
@admin_level_required(3)
def image_posts_listing(v):
@ -72,22 +54,51 @@ def image_posts_listing(v):
return render_template("admin/image_posts.html", v=v, listing=posts, next_exists=next_exists, page=page, sort="new")
@app.get("/admin/flagged/posts")
@admin_level_required(3)
def flagged_posts(v):
page = max(1, int(request.args.get("page", 1)))
posts = g.db.query(Submission).filter_by(
is_approved=0,
is_banned=False
).join(Submission.flags
).options(contains_eager(Submission.flags)
).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
listing = [p.id for p in posts]
next_exists = (len(listing) == 26)
listing = listing[:25]
listing = get_posts(listing, v=v)
return render_template("admin/flagged_posts.html",
next_exists=next_exists, listing=listing, page=page, v=v)
@app.get("/admin/flagged/comments")
@admin_level_required(3)
def flagged_comments(v):
page = max(1, int(request.args.get("page", 1)))
comments = g.db.query(Comment).filter_by(is_approved=0, is_banned=False).order_by(Comment.id.desc())
comments = [c for c in comments if c.active_flags > 0]
posts = g.db.query(Comment
).filter_by(
is_approved=0,
is_banned=False
).join(Comment.flags).options(contains_eager(Comment.flags)
).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
firstrange = 25 * (page - 1)
secondrange = firstrange+26
comments = comments[firstrange:secondrange]
next_exists = (len(comments) == 26)
listing = [p.id for p in posts]
next_exists = (len(listing) == 26)
listing = listing[:25]
listing = get_comments(listing, v=v)
return render_template("admin/flagged_comments.html",
next_exists=next_exists,
listing=comments,
listing=listing,
page=page,
v=v,
standalone=True)