diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index fb0a45101..df76d8e11 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -1,7 +1,7 @@ {% extends 'layout.html' %} {% load i18n %}{% load bookwyrm_tags %}{% load humanize %}{% load utilities %} -{% block title %}{{ book.title }}{% endblock %} +{% block title %}{{ book|title }}{% endblock %} {% block content %} {% with user_authenticated=request.user.is_authenticated can_edit_book=perms.bookwyrm.edit_book %} @@ -137,7 +137,7 @@ {# user's relationship to the book #}
- {% for shelf in user_shelves %} + {% for shelf in user_shelfbooks %}

{% blocktrans with path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}This edition is on your {{ shelf_name }} shelf.{% endblocktrans %} {% include 'snippets/shelf_selector.html' with current=shelf.shelf %} diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index ef3a6e28c..a4b9f312a 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -62,13 +62,16 @@ class Book(View): queryset = queryset.filter(user=request.user) else: queryset = reviews.exclude(Q(content__isnull=True) | Q(content="")) + queryset = queryset.select_related("user") paginated = Paginator(queryset, PAGE_LENGTH) data = { "book": book, "statuses": paginated.get_page(request.GET.get("page")), "review_count": reviews.count(), - "ratings": reviews.filter(Q(content__isnull=True) | Q(content="")) + "ratings": reviews.filter( + Q(content__isnull=True) | Q(content="") + ).select_related("user") if not user_statuses else None, "rating": reviews.aggregate(Avg("rating"))["rating__avg"], @@ -89,15 +92,15 @@ class Book(View): ) data["readthroughs"] = readthroughs - data["user_shelves"] = models.ShelfBook.objects.filter( + data["user_shelfbooks"] = models.ShelfBook.objects.filter( user=request.user, book=book - ) + ).select_related("shelf") data["other_edition_shelves"] = models.ShelfBook.objects.filter( ~Q(book=book), user=request.user, book__parent_work=book.parent_work, - ) + ).select_related("shelf", "book") data["user_statuses"] = { "review_count": book.review_set.filter(user=request.user).count(),