mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 17:41:08 +00:00
Merge pull request #820 from mouse-reeve/paginate-editions
Paginates editions page
This commit is contained in:
commit
f07f822d36
2 changed files with 11 additions and 1 deletions
|
@ -33,4 +33,8 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{% include 'snippets/pagination.html' with page=editions path=request.path %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -250,6 +250,11 @@ class Editions(View):
|
|||
""" list of editions of a book """
|
||||
work = get_object_or_404(models.Work, id=book_id)
|
||||
|
||||
try:
|
||||
page = int(request.GET.get("page", 1))
|
||||
except ValueError:
|
||||
page = 1
|
||||
|
||||
if is_api_request(request):
|
||||
return ActivitypubResponse(work.to_edition_list(**request.GET))
|
||||
filters = {}
|
||||
|
@ -262,8 +267,9 @@ class Editions(View):
|
|||
editions = work.editions.order_by("-edition_rank").all()
|
||||
languages = set(sum([e.languages for e in editions], []))
|
||||
|
||||
paginated = Paginator(editions.filter(**filters).all(), PAGE_LENGTH)
|
||||
data = {
|
||||
"editions": editions.filter(**filters).all(),
|
||||
"editions": paginated.page(page),
|
||||
"work": work,
|
||||
"languages": languages,
|
||||
"formats": set(
|
||||
|
|
Loading…
Reference in a new issue