Updates view logic

This commit is contained in:
Ross Chapman 2023-12-14 13:04:45 -08:00
parent bd3acdbf31
commit 44d21d1ba4
2 changed files with 8 additions and 10 deletions

View file

@ -106,16 +106,11 @@
(showing {{ start }}-{{ end }})
{% endblocktrans %}
{% endif %}
{% if show_shelves_filter_msg %}
- {% trans "We couldn't find any books that matched" %} "{{ shelves_filter_query }}"
{% endif %}
</span>
{% endif %}
{% endwith %}
</h2>
{% if books|length > 0 %}
{% include 'shelf/shelves_filters.html' with user=user query=query %}
{% endif %}
{% include 'shelf/shelves_filters.html' with user=user query=query %}
</div>
{% if is_self and shelf.id %}
@ -215,7 +210,12 @@
</tbody>
</table>
{% else %}
<p><em>{% trans "This shelf is empty." %}</em></p>
<p><em>{% if shelves_filter_query %}
{% trans "We couldn't find any books that matched" %} "{{ shelves_filter_query }}"
{% else %}
{% trans "This shelf is empty." %}
{% endif %}
</em></p>
{% endif %}
</div>

View file

@ -94,8 +94,7 @@ class Shelf(View):
books = sort_books(books, request.GET.get("sort"))
if shelves_filter_query:
books = search(shelves_filter_query, books=books) or books
show_shelves_filter_msg = True
books = search(shelves_filter_query, books=books)
paginated = Paginator(
books,
@ -115,7 +114,6 @@ class Shelf(View):
page.number, on_each_side=2, on_ends=1
),
"shelves_filter_query": shelves_filter_query,
"show_shelves_filter_msg": show_shelves_filter_msg,
}
return TemplateResponse(request, "shelf/shelf.html", data)