diff options
author | hardythe1 | 2014-03-15 18:02:06 +0530 |
---|---|---|
committer | hardythe1 | 2014-03-15 18:02:06 +0530 |
commit | e1e7ff0ebfc5cb8dfe8fb69aad4fe481bb7b3ec7 (patch) | |
tree | 5ca6dad87dca756ce45197d077810d134c9802eb | |
parent | 20c0046f3be8d10a3ceddabdcc395484a1f781ef (diff) | |
download | Python-TBC-Interface-e1e7ff0ebfc5cb8dfe8fb69aad4fe481bb7b3ec7.tar.gz Python-TBC-Interface-e1e7ff0ebfc5cb8dfe8fb69aad4fe481bb7b3ec7.tar.bz2 Python-TBC-Interface-e1e7ff0ebfc5cb8dfe8fb69aad4fe481bb7b3ec7.zip |
solving issue with browsing books
-rw-r--r-- | tbc/views.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tbc/views.py b/tbc/views.py index e7d6d51..2d2710c 100644 --- a/tbc/views.py +++ b/tbc/views.py @@ -480,7 +480,7 @@ def BrowseBooks(request): category = None images = [] book_images = [] - books = [] + books = None if request.user.is_anonymous(): context['anonymous'] = True else: @@ -492,13 +492,18 @@ def BrowseBooks(request): books = Book.objects.filter(approved=True) if request.method == "POST": category = request.POST['category'] - return HttpResponse(category) + if category == "all": + books = Book.objects.filter(approved=True) + else: + books = Book.objects.filter(category=category) + return HttpResponse(books) else: - for book in books: - images.append(ScreenShots.objects.filter(book=book)[0]) - for i in range(len(books)): - obj = {'book':books[i], 'image':images[i]} - book_images.append(obj) + books = Book.objects.filter(approved=True) + for book in books: + images.append(ScreenShots.objects.filter(book=book)[0]) + for i in range(len(books)): + obj = {'book':books[i], 'image':images[i]} + book_images.append(obj) context['items'] = book_images context['category'] = category return render_to_response('tbc/browse-books.html', context) |