Merge pull request #1048 from bookwyrm-social/shelf-pagination

Adds elided page range to shelf pagination
This commit is contained in:
Mouse Reeve 2021-05-04 08:32:57 -07:00 committed by GitHub
commit 33ec315fbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -57,12 +57,16 @@ 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)