Max on books shown from shelves in suggestions bar

This commit is contained in:
Mouse Reeve
2020-11-07 11:54:32 -08:00
parent 1b50e83c95
commit 794aeb299c
2 changed files with 9 additions and 4 deletions

View File

@ -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(