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()] 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) return render_template("shadowbanned.html", v=v, users=users)
@app.get("/admin/filtered_submissions") @app.get("/admin/filtered/posts")
@admin_level_required(2) @admin_level_required(2)
def filtered_submissions(v): def filtered_submissions(v):
try: page = int(request.values.get('page', 1)) 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") 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") @app.post("/admin/update_filter_status")
@admin_level_required(2) @admin_level_required(2)
def update_filter_status(v): def update_filter_status(v):

View file

@ -19,7 +19,7 @@
<h4>Filtering</h4> <h4>Filtering</h4>
<ul> <ul>
<li><a href="/admin/filtered_submissions">Filtered Submissions</a></li> <li><a href="/admin/filtered/posts">Filtered Posts/Comments</a></li>
</ul> </ul>
<h4>Users</h4> <h4>Users</h4>

View file

@ -0,0 +1,26 @@
{% extends "admin/filtered_submissions.html" %}
{% block title %}
<title>Filtered Comments</title>
{% endblock %}
{% block listing %}
<div class="posts">
{% with comments=listing %}
{% include "comments.html" %}
{% endwith %}
{% if not listing %}
<div class="row no-gutters">
<div class="col">
<div class="text-center py-7">
<div class="h4 p-2">There are no comments here (yet).</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View file

@ -14,13 +14,26 @@
{% endblock %} {% endblock %}
{% block title %} {% block title %}
<title>Filtered Submissions</title> <title>Filtered Posts</title>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<ul class="nav post-nav py-2">
<li class="nav-item">
<a class="nav-link {% if request.path=="/admin/filtered/posts" %} active{% endif %}" href="/admin/filtered/posts">
<div>Posts</div>
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if request.path=="/admin/filtered/comments" %} active{% endif %}" href="/admin/filtered/comments">
<div>Comments</div>
</a>
</li>
</ul>
<div class="row no-gutters"> <div class="row no-gutters">
<div class="col"> <div class="col">