Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2020-11-06 20:51:41 -08:00
commit bc62ed231f
2 changed files with 7 additions and 3 deletions

View file

@ -11,7 +11,7 @@
<div class="tabs is-small">
<ul>
{% for shelf in suggested_books %}
{% if shelf.books.count %}
{% if shelf.books %}
{% with shelf_counter=forloop.counter %}
<li>
<p>{{ shelf.name }}</p>

View file

@ -3,7 +3,7 @@ import re
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.postgres.search import TrigramSimilarity
from django.db.models import Avg, Count, Q
from django.db.models import Avg, Q
from django.http import HttpResponseBadRequest, HttpResponseNotFound,\
JsonResponse
from django.core.exceptions import PermissionDenied
@ -67,9 +67,13 @@ def home_tab(request, tab):
for preset in preset_shelves:
limit = max_books - book_count
shelf = request.user.shelf_set.get(identifier=preset)
shelf_books = shelf.shelfbook_set.order_by(
'-updated_date'
).all()[:limit]
shelf_preview = {
'name': shelf.name,
'books': shelf.books.all()[:limit]
'books': [s.book for s in shelf_books]
}
suggested_books.append(shelf_preview)
book_count += len(shelf_preview['books'])