forked from rDrama/rDrama
1
0
Fork 0

paginate /banned

master
Aevann 2024-02-03 00:31:10 +02:00
parent 76781e60c9
commit 55d6ac43e5
2 changed files with 41 additions and 16 deletions

View File

@ -328,13 +328,32 @@ def user_voted_comments(v, username):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def banned(v):
sort = request.values.get("sort")
page = get_page()
users = g.db.query(User).filter(
User.is_banned != None,
or_(User.unban_utc == 0, User.unban_utc > time.time()),
).order_by(User.ban_reason)
)
users = users.all()
return render_template("banned.html", v=v, users=users)
total = users.count()
if sort == "name":
key = User.username
elif sort == "truescore":
key = User.truescore.desc()
elif sort == "ban_reason":
key = User.ban_reason
elif sort == "banned_by":
key = User.is_banned
else:
sort = "unban_utc"
key = User.unban_utc
users = users.order_by(key).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE)
return render_template("banned.html", v=v, users=users, sort=sort, total=total, page=page)
@app.get("/grassed")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)

View File

@ -6,24 +6,26 @@
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th>#</th>
<th>Name</th>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<th>Last Active</th>
{%- endif %}
<th>Truescore</th>
<th>Ban reason</th>
<th>Banned by</th>
<th>Unban in</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=="ban_reason" %}disabled{% endif %}>
<a href="?sort=ban_reason">Ban reason</a>
</th>
<th class="disable-sort-click" {% if sort=="banned_by" %}disabled{% endif %}>
<a href="?sort=banned_by">Banned by</a>
</th>
<th class="disable-sort-click" {% if sort=="unban_utc" %}disabled{% endif %}>
<a href="?sort=unban_utc">Unban on</a>
</th>
</tr>
</thead>
{% for user in users %}
<tr>
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<td {% if user.last_active %}data-time="{{user.last_active}}"{% endif %}></td>
{%- endif %}
<td>{{user.truescore}}</td>
<td>{{user.ban_reason | safe}}</td>
<td>{{user.banned_by | safe}}</td>
@ -33,3 +35,7 @@
</table>
</div>
{% endblock %}
{% block pagenav %}
{% include "pagination.html" %}
{% endblock %}