forked from MarseyWorld/MarseyWorld
paginate /blocks
parent
53641e9a1b
commit
76781e60c9
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from shutil import copyfile
|
||||
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import func, asc, text
|
||||
from files.helpers.media import *
|
||||
|
||||
import files.helpers.stats as statshelper
|
||||
|
@ -349,12 +349,28 @@ def badges(v):
|
|||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@auth_required
|
||||
def blocks(v):
|
||||
sort = request.values.get("sort")
|
||||
|
||||
page = get_page()
|
||||
|
||||
blocks = g.db.query(UserBlock).options(
|
||||
joinedload(UserBlock.user),
|
||||
joinedload(UserBlock.target),
|
||||
).order_by(UserBlock.created_utc.desc())
|
||||
)
|
||||
|
||||
return render_template("blocks.html", v=v, blocks=blocks)
|
||||
total = blocks.count()
|
||||
|
||||
if sort == "user":
|
||||
key = asc(text('users_1_username'))
|
||||
elif sort == "target":
|
||||
key = asc(text('users_2_username'))
|
||||
else:
|
||||
sort = "time"
|
||||
key = UserBlock.created_utc.desc()
|
||||
|
||||
blocks = blocks.order_by(key).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE)
|
||||
|
||||
return render_template("blocks.html", v=v, blocks=blocks, sort=sort, total=total, page=page)
|
||||
|
||||
@app.get("/notification_mutes")
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
|
|
|
@ -6,9 +6,15 @@
|
|||
<table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Target</th>
|
||||
<th>Blocked on</th>
|
||||
<th class="disable-sort-click" {% if sort=="user" %}disabled{% endif %}>
|
||||
<a href="?sort=user">User</a>
|
||||
</th>
|
||||
<th class="disable-sort-click" {% if sort=="target" %}disabled{% endif %}>
|
||||
<a href="?sort=target">Target</a>
|
||||
</th>
|
||||
<th class="disable-sort-click" {% if sort=="time" %}disabled{% endif %}>
|
||||
<a href="?sort=time">Blocked on</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for block in blocks %}
|
||||
|
@ -29,3 +35,7 @@
|
|||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
|
||||
<div class="pt-3 container">
|
||||
{% block content %}{% endblock %}
|
||||
{% block pagenav %}{% endblock %}
|
||||
</div>
|
||||
|
||||
<div class="toast clipboard" id="toast-clipboard-success" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
|
||||
|
|
Loading…
Reference in New Issue