Paginate followers/following pages

This commit is contained in:
Mouse Reeve 2021-04-26 10:26:27 -07:00
parent 99efe6b290
commit 786cf4fb97
4 changed files with 9 additions and 3 deletions

View file

@ -29,4 +29,6 @@
<div>{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}</div>
{% endif %}
</div>
{% include 'snippets/pagination.html' with page=followers path=request.path %}
{% endblock %}

View file

@ -29,4 +29,6 @@
<div>{% blocktrans with username=user|username %}{{ username }} isn't following any users{% endblocktrans %}</div>
{% endif %}
</div>
{% include 'snippets/pagination.html' with page=following path=request.path %}
{% endblock %}

View file

@ -106,10 +106,11 @@ class Followers(View):
if is_api_request(request):
return ActivitypubResponse(user.to_followers_activity(**request.GET))
paginated = Paginator(user.followers.all(), PAGE_LENGTH)
data = {
"user": user,
"is_self": request.user.id == user.id,
"followers": user.followers.all(),
"followers": paginated.page(request.GET.get("page", 1)),
}
return TemplateResponse(request, "user/followers.html", data)
@ -131,10 +132,11 @@ class Following(View):
if is_api_request(request):
return ActivitypubResponse(user.to_following_activity(**request.GET))
paginated = Paginator(user.followers.all(), PAGE_LENGTH)
data = {
"user": user,
"is_self": request.user.id == user.id,
"following": user.following.all(),
"following": paginated.page(request.GET.get("page", 1)),
}
return TemplateResponse(request, "user/following.html", data)