From 07d59c8c097f003d5b332471e0104057ea722356 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 18 May 2021 11:09:19 -0700 Subject: [PATCH] Don't show ratings below user statuses --- bookwyrm/templates/book/book.html | 4 +++- bookwyrm/views/books.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 0aa64836..53c9c067 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -195,7 +195,7 @@ {% endif %}
{% if request.user.is_authenticated %} - {% if user_statuses.review_count or user_statuses.comment_count or user_stuatses.quotation_count %} + {% if user_statuses.review_count or user_statuses.comment_count or user_statuses.quotation_count %}
{% endfor %} + {% if ratings %}
{% for rating in ratings %} {% with user=rating.user %} @@ -265,6 +266,7 @@ {% endwith %} {% endfor %}
+ {% endif %}
{% include 'snippets/pagination.html' with page=statuses path=request.path anchor="#reviews" %}
diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index 6005c9fd..27bdddb1 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -30,6 +30,7 @@ class Book(View): def get(self, request, book_id, user_statuses=False): """info about a book""" + user_statuses = user_statuses if request.user.is_authenticated else False try: book = models.Book.objects.select_subclasses().get(id=book_id) except models.Book.DoesNotExist: @@ -51,7 +52,7 @@ class Book(View): ) # the reviews to show - if user_statuses and request.user.is_authenticated: + if user_statuses: if user_statuses == "review": queryset = book.review_set elif user_statuses == "comment": @@ -67,7 +68,9 @@ class Book(View): "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="")) + if not user_statuses + else None, "rating": reviews.aggregate(Avg("rating"))["rating__avg"], "lists": privacy_filter( request.user, book.list_set.filter(listitem__approved=True)