mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Merge pull request #302 from mouse-reeve/shelf-preview-max
Max for books shown from shelves in suggestions bar
This commit is contained in:
commit
7663bd620a
2 changed files with 9 additions and 4 deletions
|
@ -14,7 +14,9 @@
|
|||
{% if shelf.books %}
|
||||
{% with shelf_counter=forloop.counter %}
|
||||
<li>
|
||||
<p>{{ shelf.name }}</p>
|
||||
<p>
|
||||
{{ shelf.name }}
|
||||
</p>
|
||||
<div class="tabs is-small is-toggle">
|
||||
<ul>
|
||||
{% for book in shelf.books %}
|
||||
|
|
|
@ -87,10 +87,13 @@ def home_tab(request, tab):
|
|||
def get_suggested_books(user, max_books=5):
|
||||
''' helper to get a user's recent books '''
|
||||
book_count = 0
|
||||
preset_shelves = ['reading', 'read', 'to-read']
|
||||
preset_shelves = [
|
||||
('reading', max_books), ('read', 2), ('to-read', max_books)
|
||||
]
|
||||
suggested_books = []
|
||||
for preset in preset_shelves:
|
||||
limit = max_books - book_count
|
||||
for (preset, shelf_max) in preset_shelves:
|
||||
limit = shelf_max if shelf_max < (max_books - book_count) \
|
||||
else max_books - book_count
|
||||
shelf = user.shelf_set.get(identifier=preset)
|
||||
|
||||
shelf_books = shelf.shelfbook_set.order_by(
|
||||
|
|
Loading…
Reference in a new issue