forked from mirrors/bookwyrm
Merge pull request #1048 from bookwyrm-social/shelf-pagination
Adds elided page range to shelf pagination
This commit is contained in:
commit
33ec315fbf
2 changed files with 7 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue