From 7dfc991468a09f26e9f0d6e9ac44ef33ac9b568b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 3 May 2021 14:47:27 -0700 Subject: [PATCH] Adds elided page range to shelf pagination --- bookwyrm/views/list.py | 3 ++- bookwyrm/views/shelf.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index eac0f6572..bfd617907 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -18,6 +18,7 @@ from django.views.decorators.http import require_POST from bookwyrm import forms, models from bookwyrm.activitypub import ActivitypubResponse from bookwyrm.connectors import connector_manager +from bookwyrm.settings import PAGE_LENGTH from .helpers import is_api_request, privacy_filter from .helpers import get_user_from_username @@ -133,7 +134,7 @@ class List(View): .order_by(directional_sort_by) ) - paginated = Paginator(items, 12) + paginated = Paginator(items, PAGE_LENGTH) if query and request.user.is_authenticated: # search for books diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index 94507d46e..99ec5ef1d 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -57,12 +57,17 @@ class Shelf(View): PAGE_LENGTH, ) + page = paginated.get_page(request.GET.get("page")) data = { "user": user, "is_self": is_self, "shelves": shelves.all(), "shelf": shelf, - "books": paginated.get_page(request.GET.get("page")), + "books": page, + "page_range": paginated.get_elided_page_range( + page.number, on_each_side=2, on_ends=1 + ) + } return TemplateResponse(request, "user/shelf/shelf.html", data)