mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Adds elided page range to shelf pagination
This commit is contained in:
parent
7db8e249cc
commit
7dfc991468
2 changed files with 8 additions and 2 deletions
|
@ -18,6 +18,7 @@ from django.views.decorators.http import require_POST
|
||||||
from bookwyrm import forms, models
|
from bookwyrm import forms, models
|
||||||
from bookwyrm.activitypub import ActivitypubResponse
|
from bookwyrm.activitypub import ActivitypubResponse
|
||||||
from bookwyrm.connectors import connector_manager
|
from bookwyrm.connectors import connector_manager
|
||||||
|
from bookwyrm.settings import PAGE_LENGTH
|
||||||
from .helpers import is_api_request, privacy_filter
|
from .helpers import is_api_request, privacy_filter
|
||||||
from .helpers import get_user_from_username
|
from .helpers import get_user_from_username
|
||||||
|
|
||||||
|
@ -133,7 +134,7 @@ class List(View):
|
||||||
.order_by(directional_sort_by)
|
.order_by(directional_sort_by)
|
||||||
)
|
)
|
||||||
|
|
||||||
paginated = Paginator(items, 12)
|
paginated = Paginator(items, PAGE_LENGTH)
|
||||||
|
|
||||||
if query and request.user.is_authenticated:
|
if query and request.user.is_authenticated:
|
||||||
# search for books
|
# search for books
|
||||||
|
|
|
@ -57,12 +57,17 @@ class Shelf(View):
|
||||||
PAGE_LENGTH,
|
PAGE_LENGTH,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
page = paginated.get_page(request.GET.get("page"))
|
||||||
data = {
|
data = {
|
||||||
"user": user,
|
"user": user,
|
||||||
"is_self": is_self,
|
"is_self": is_self,
|
||||||
"shelves": shelves.all(),
|
"shelves": shelves.all(),
|
||||||
"shelf": shelf,
|
"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)
|
return TemplateResponse(request, "user/shelf/shelf.html", data)
|
||||||
|
|
Loading…
Reference in a new issue