use new pagination system in /transfers

master
Aevann 2023-05-05 04:06:25 +03:00
parent 74bc00199d
commit eff429223b
2 changed files with 5 additions and 23 deletions

View File

@ -370,7 +370,7 @@ def transfers_id(id, v):
if not transfer: abort(404)
return render_template("transfers.html", v=v, page=1, comments=[transfer], standalone=True, next_exists=False)
return render_template("transfers.html", v=v, page=1, comments=[transfer], standalone=True, next_exists=1)
@app.get("/transfers")
@limiter.limit(DEFAULT_RATELIMIT)
@ -378,14 +378,13 @@ def transfers_id(id, v):
@auth_required
def transfers(v:User):
comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("%</a> has transferred %")).order_by(Comment.id.desc())
comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("%</a> has transferred %"))
try: page = max(int(request.values.get("page", 1)), 1)
except: page = 1
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all()
next_exists = len(comments) > PAGE_SIZE
comments = comments[:PAGE_SIZE]
next_exists = comments.count()
comments = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
if v.client:
return {"data": [x.json(g.db) for x in comments]}

View File

@ -13,24 +13,7 @@
</div>
{% endblock %}
{% block pagenav %}
<nav>
<ul class="pagination pagination-sm mb-0">
{% if page>1 %}
<li class="page-item">
<small><a class="page-link" href="?page={{page-1}}" tabindex="-1">Prev</a></small>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link">Prev</span></li>
{% endif %}
{% if next_exists %}
<li class="page-item">
<small><a class="page-link" href="?page={{page+1}}">Next</a></small>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link">Next</span></li>
{% endif %}
</ul>
</nav>
{% include "pagination.html" %}
<div class="toast clipboard" id="toast-success" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body text-center">
<i class="fas fa-check-circle text-success mr-2"></i>Link copied to clipboard