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