use new pagination system in /transfers
parent
74bc00199d
commit
eff429223b
|
@ -370,7 +370,7 @@ def transfers_id(id, v):
|
||||||
|
|
||||||
if not transfer: abort(404)
|
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")
|
@app.get("/transfers")
|
||||||
@limiter.limit(DEFAULT_RATELIMIT)
|
@limiter.limit(DEFAULT_RATELIMIT)
|
||||||
|
@ -378,14 +378,13 @@ def transfers_id(id, v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def transfers(v:User):
|
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)
|
try: page = max(int(request.values.get("page", 1)), 1)
|
||||||
except: page = 1
|
except: page = 1
|
||||||
|
|
||||||
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all()
|
next_exists = comments.count()
|
||||||
next_exists = len(comments) > PAGE_SIZE
|
comments = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
|
||||||
comments = comments[:PAGE_SIZE]
|
|
||||||
|
|
||||||
if v.client:
|
if v.client:
|
||||||
return {"data": [x.json(g.db) for x in comments]}
|
return {"data": [x.json(g.db) for x in comments]}
|
||||||
|
|
|
@ -13,24 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block pagenav %}
|
{% block pagenav %}
|
||||||
<nav>
|
{% include "pagination.html" %}
|
||||||
<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>
|
|
||||||
<div class="toast clipboard" id="toast-success" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
|
<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">
|
<div class="toast-body text-center">
|
||||||
<i class="fas fa-check-circle text-success mr-2"></i>Link copied to clipboard
|
<i class="fas fa-check-circle text-success mr-2"></i>Link copied to clipboard
|
||||||
|
|
Loading…
Reference in New Issue