def book(request, isbn13): book = get_adapter().book(isbn13) serializer = BookSerializer(book, request) context = { "book": serializer.data } return render(request, 'traditional/pages/book.html', context)
def books(request): page = request.GET.get('page', 1) results = get_adapter().books(page) serializer = BookListSerializer(results, request) context = { "books": serializer.data, } return render(request, 'traditional/pages/books.html', context)
def add_my_bookmarks(request): isbn13 = request.GET.get('isbn13') book = get_adapter().book(isbn13) success, message = Bookmark.add_my_bookmarks(request.user, book) response = { "success": success, "message": message } return JsonResponse(response)
def search(request): q, page = request.GET.get('q', ""), request.GET.get('page', 1) results = get_adapter().search(q, page) is_lucky = request.GET.get('lucky', False) if is_lucky and len(results) > 0: isbn13 = results[0]['isbn13'] url = reverse('traditional:book', kwargs={"isbn13": isbn13}) return HttpResponseRedirect(url) serializer = BookListSerializer(results, request) context = { "books": serializer.data, } return render(request, 'traditional/pages/search.html', context)
def get(self, request): adapter = get_adapter() results = adapter.books(paginated=False) return Response({"books": results})
def get(self, request, isbn13): adapter = get_adapter() results = adapter.book(isbn13) return Response(results)
def get(self, request): q = request.query_params.get('q') adapter = get_adapter() results = adapter.search(q) return Response(results)
def get(self, request, *args, **kwargs): adapter = get_adapter() results = adapter.books() return Response(results)