diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 69cbb9eb8..2fe9cdae4 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -215,10 +215,10 @@ {% endif %} - {% with work=book.parent_work %} + {% with work=book.parent_work editions_count=book.parent_work.editions.count %}

- {% blocktrans trimmed count counter=work.editions.count with count=work.editions.count|intcomma %} + {% blocktrans trimmed count counter=editions_count with count=editions_count|intcomma %} {{ count }} edition {% plural %} {{ count }} editions diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index e838ead12..1227e39c4 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -25,6 +25,7 @@ {% block body %}

diff --git a/bookwyrm/templates/snippets/create_status/comment.html b/bookwyrm/templates/snippets/create_status/comment.html index 65b322699..1186cc71c 100644 --- a/bookwyrm/templates/snippets/create_status/comment.html +++ b/bookwyrm/templates/snippets/create_status/comment.html @@ -19,9 +19,9 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j {# Supplemental fields #}
{% active_shelf book as active_shelf %} - {% if active_shelf.shelf.identifier == 'reading' and book.latest_readthrough %} - + {% if active_shelf.shelf.identifier == 'reading' %} {% with readthrough=book.latest_readthrough %} + {% if readthrough %}
@@ -66,6 +66,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j

{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}

{% endif %}
+ {% endif %} {% endwith %} {% endif %}
diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index 6d7aeb239..17218b93e 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -237,16 +237,24 @@ def feed_page_data(user): def get_suggested_books(user, max_books=5): """helper to get a user's recent books""" book_count = 0 - preset_shelves = [("reading", max_books), ("read", 2), ("to-read", max_books)] + preset_shelves = {"reading": max_books, "read": 2, "to-read": max_books} suggested_books = [] - for (preset, shelf_max) in preset_shelves: + + user_shelves = { + shelf.identifier: shelf + for shelf in user.shelf_set.filter( + identifier__in=preset_shelves.keys() + ).exclude(books__isnull=True) + } + + for preset, shelf_max in preset_shelves.items(): limit = ( shelf_max if shelf_max < (max_books - book_count) else max_books - book_count ) - shelf = user.shelf_set.get(identifier=preset) - if not shelf.books.exists(): + shelf = user_shelves.get(preset, None) + if not shelf: continue shelf_preview = {