mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
get suggested books from shelfbook
This commit is contained in:
parent
a02f380472
commit
ba97870276
2 changed files with 7 additions and 3 deletions
|
@ -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>
|
||||
|
|
|
@ -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'])
|
||||
|
|
Loading…
Reference in a new issue