forked from mirrors/bookwyrm
Book page filters ratings with empty string content
This commit is contained in:
parent
1046aa7ad2
commit
a0a8ad508a
3 changed files with 7 additions and 13 deletions
|
@ -199,13 +199,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% if not reviews %}
|
||||
<div class="block">
|
||||
<p>No reviews yet!</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="block">
|
||||
{% for review in reviews %}
|
||||
<div class="block">
|
||||
|
@ -213,9 +206,9 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="block columns">
|
||||
<div class="block is-flex is-flex-wrap-wrap">
|
||||
{% for rating in ratings %}
|
||||
<div class="column">
|
||||
<div class="block mr-5">
|
||||
<div class="media">
|
||||
<div class="media-left">{% include 'snippets/avatar.html' with user=rating.user %}</div>
|
||||
<div class="media-content">
|
||||
|
@ -236,6 +229,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<span class="is-sr-only">Leave a rating</span>
|
||||
<div class="field is-grouped stars rate-stars">
|
||||
{% for i in '12345'|make_list %}
|
||||
<form name="rate" action="/rate/" method="POST" onsubmit="return rate_stars(event)">
|
||||
<form name="rate" action="/rate/" method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
|
|
|
@ -632,7 +632,9 @@ def book_page(request, book_id):
|
|||
reviews = get_activity_feed(request.user, 'federated', model=reviews)
|
||||
|
||||
# the reviews to show
|
||||
paginated = Paginator(reviews.filter(content__isnull=False), PAGE_LENGTH)
|
||||
paginated = Paginator(reviews.exclude(
|
||||
Q(content__isnull=True) | Q(content='')
|
||||
), PAGE_LENGTH)
|
||||
reviews_page = paginated.page(page)
|
||||
|
||||
prev_page = next_page = None
|
||||
|
@ -668,7 +670,7 @@ def book_page(request, book_id):
|
|||
'title': book.title,
|
||||
'book': book,
|
||||
'reviews': reviews_page,
|
||||
'ratings': reviews.filter(content__isnull=True),
|
||||
'ratings': reviews.filter(Q(content__isnull=True) | Q(content='')),
|
||||
'rating': reviews.aggregate(Avg('rating'))['rating__avg'],
|
||||
'tags': models.UserTag.objects.filter(book=book),
|
||||
'user_tags': user_tags,
|
||||
|
|
Loading…
Reference in a new issue