forked from mirrors/bookwyrm
Paginates federated server list
This commit is contained in:
parent
62cbfe0fac
commit
158d2c5231
2 changed files with 11 additions and 2 deletions
|
@ -21,4 +21,5 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
{% include 'snippets/pagination.html' with page=servers path=request.path %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
""" manage federated servers """
|
""" manage federated servers """
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
|
from django.core.paginator import Paginator
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
|
from bookwyrm.settings import PAGE_LENGTH
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable= no-self-use
|
# pylint: disable= no-self-use
|
||||||
|
@ -18,9 +20,15 @@ class Federation(View):
|
||||||
""" what servers do we federate with """
|
""" what servers do we federate with """
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" edit form """
|
""" list of servers """
|
||||||
|
try:
|
||||||
|
page = int(request.GET.get("page", 1))
|
||||||
|
except ValueError:
|
||||||
|
page = 1
|
||||||
|
|
||||||
servers = models.FederatedServer.objects.all()
|
servers = models.FederatedServer.objects.all()
|
||||||
data = {"servers": servers}
|
paginated = Paginator(servers, PAGE_LENGTH)
|
||||||
|
data = {"servers": paginated.page(page)}
|
||||||
return TemplateResponse(request, "settings/federation.html", data)
|
return TemplateResponse(request, "settings/federation.html", data)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue