forked from rDrama/rDrama
1
0
Fork 0

use new pagination system in profile views

master
Aevann 2023-05-05 04:08:40 +03:00
parent eff429223b
commit 5d1737c16c
2 changed files with 4 additions and 22 deletions

View File

@ -797,10 +797,9 @@ def visitors(v:User, username:str):
try: page = int(request.values.get("page", 1))
except: page = 1
views = g.db.query(ViewerRelationship).filter_by(user_id=u.id).order_by(ViewerRelationship.last_view_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all()
next_exists = (len(views) > PAGE_SIZE)
views = views[:PAGE_SIZE]
views = g.db.query(ViewerRelationship).filter_by(user_id=u.id)
next_exists = views.count()
views = views.order_by(ViewerRelationship.last_view_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
return render_template("userpage/views.html", v=v, u=u, views=views, next_exists=next_exists, page=page)

View File

@ -24,22 +24,5 @@
{% endblock %}
{% block pagenav %}
<nav>
<ul class="pagination pagination-sm py-3 pl-3 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" %}
{% endblock %}