paginate /admin/shadowbanned

pull/222/head
Aevann 2024-02-03 01:15:12 +02:00
parent 8186a9fbc7
commit 572f49563e
2 changed files with 42 additions and 10 deletions

View File

@ -277,9 +277,29 @@ def revert_actions(v, username):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@admin_level_required(PERMS['USER_SHADOWBAN'])
def shadowbanned(v):
users = g.db.query(User).filter(User.shadowbanned != None).order_by(User.ban_reason).all()
sort = request.values.get("sort")
return render_template("admin/shadowbanned.html", v=v, users=users)
page = get_page()
users = g.db.query(User).filter(User.shadowbanned != None)
total = users.count()
if sort == "name":
key = User.username
elif sort == "truescore":
key = User.truescore.desc()
elif sort == "shadowban_reason":
key = User.ban_reason
elif sort == "shadowbanned_by":
key = User.shadowbanned
else:
sort = "last_active"
key = User.last_active
users = users.order_by(key).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE)
return render_template("admin/shadowbanned.html", v=v, users=users, sort=sort, total=total, page=page)
@app.get("/admin/image_posts")

View File

@ -6,24 +6,36 @@
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th>#</th>
<th>Name</th>
<th>Last Active</th>
<th>Truescore</th>
<th>Shadowbanned by</th>
<th>Shadowban reason</th>
<th class="disable-sort-click" {% if sort=="name" %}disabled{% endif %}>
<a href="?sort=name">Name</a>
</th>
<th class="disable-sort-click" {% if sort=="truescore" %}disabled{% endif %}>
<a href="?sort=truescore">Truescore</a>
</th>
<th class="disable-sort-click" {% if sort=="shadowban_reason" %}disabled{% endif %}>
<a href="?sort=shadowban_reason">Shadowban reason</a>
</th>
<th class="disable-sort-click" {% if sort=="shadowbanned_by" %}disabled{% endif %}>
<a href="?sort=shadowbanned_by">Shadowbanned by</a>
</th>
<th class="disable-sort-click" {% if sort=="last_active" %}disabled{% endif %}>
<a href="?sort=last_active">Last Active</a>
</th>
</tr>
</thead>
{% for user in users %}
<tr>
<td>{{loop.index}}</td>
<td data-sort-key="{{user.username.lower() if user else ''}}">{%- include 'user_in_table.html' -%}</td>
<td {% if user.last_active %}data-time="{{user.last_active}}"{% endif %}></td>
<td>{{user.truescore}}</td>
<td><a href="/@{{user.shadowbanner}}">{{user.shadowbanner}}</a></td>
<td><a href="/{{user.shadowbanned_by}}">{{user.shadowbanned_by}}</a></td>
<td>{{user.ban_reason | safe}}</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}
{% block pagenav %}
{% include "pagination.html" %}
{% endblock %}