diff --git a/files/routes/static.py b/files/routes/static.py index 8e723c9f4..220623eaf 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -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) diff --git a/files/templates/blocks.html b/files/templates/blocks.html index a1540cc64..f5b880188 100644 --- a/files/templates/blocks.html +++ b/files/templates/blocks.html @@ -6,9 +6,15 @@ - - - + + + {% for block in blocks %} @@ -29,3 +35,7 @@
UserTargetBlocked on + User + + Target + + Blocked on +
{% endblock %} + +{% block pagenav %} + {% include "pagination.html" %} +{% endblock %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index affb5f0d9..1a7c6b043 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -76,6 +76,7 @@
{% block content %}{% endblock %} + {% block pagenav %}{% endblock %}