Get discover books to work while not logged in.

This commit is contained in:
Adam Kelly 2020-03-27 15:10:04 +00:00
parent b58a362df2
commit 2ebc758dae
2 changed files with 7 additions and 5 deletions

View file

@ -1,4 +1,5 @@
{% load fr_display %}
{% if request.user.is_authenticated %}
{% if not pulldown %}
<form name="shelve" action="/shelve/" method="post">
@ -25,3 +26,4 @@
</form>
{% endif %}
{% endif %}

View file

@ -98,11 +98,11 @@ def home_tab(request, tab):
def books_page(request):
''' discover books '''
recent_books = models.Book.objects.filter(
~Q(shelfbook__shelf__user=request.user)
).order_by(
'-created_date'
)[:50]
recent_books = models.Book.objects
if request.user.is_authenticated:
recent_books = recent_books.filter(~Q(shelfbook__shelf__user=request.user))
recent_books = recent_books.order_by('-created_date')[:50]
data = {
'books': recent_books,
}