Max on books shown from shelves in suggestions bar
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user