X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ed884ab790d0446fae6e73f3f333d6b08c792f2a..b048f3425b94d66c7f8eae2005de78bf94896f4f:/src/api/handlers.py?ds=inline diff --git a/src/api/handlers.py b/src/api/handlers.py index b3edaef60..af01337d0 100644 --- a/src/api/handlers.py +++ b/src/api/handlers.py @@ -401,6 +401,11 @@ class FilterBooksHandler(AnonymousBooksHandler): return QuerySetProxy(filtered_books) +class BookPreviewHandler(BookDetailHandler): + def read(self, request): + return Book.objects.filter(preview=True) + + # add categorized tags fields for Book def _tags_getter(category): @classmethod @@ -740,13 +745,14 @@ class UserLikeHandler(BaseHandler): return rc.NOT_FOUND return {'likes': likes(request.user, book)} - def create(self, request, slug, action='like'): + def create(self, request, slug): if not request.user.is_authenticated(): return rc.FORBIDDEN try: book = Book.objects.get(slug=slug) except Book.DoesNotExist: return rc.NOT_FOUND + action = request.GET.get('action', 'like') if action == 'like': book.like(request.user) elif action == 'unlike':