X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/51369735b0c2f71ee63c1403da3254d5efed2b93..187d054620e6e005bed835fbdcb34a0098ffe98e:/src/api/handlers.py diff --git a/src/api/handlers.py b/src/api/handlers.py index 6f7179bd5..97b82fc7d 100644 --- a/src/api/handlers.py +++ b/src/api/handlers.py @@ -122,14 +122,12 @@ class BookDetails(object): @classmethod def url(cls, book): """ Returns Book's URL on the site. """ - return WL_BASE + book.get_absolute_url() @classmethod def children(cls, book): """ Returns all children for a book. """ - - return book.children.all() + return book.children.order_by('parent_number', 'sort_key') @classmethod def media(cls, book): @@ -158,7 +156,7 @@ class BookDetailHandler(BaseHandler, BookDetails): """ allowed_methods = ['GET'] fields = ['title', 'parent', 'children'] + Book.formats + [ - 'media', 'url', 'cover', 'cover_thumb'] + [ + 'media', 'url', 'cover', 'cover_thumb', 'fragment_data'] + [ category_plural[c] for c in book_tag_categories] @piwik_track @@ -281,7 +279,7 @@ class EBooksHandler(AnonymousBooksHandler): class FilterBooksHandler(AnonymousBooksHandler): fields = book_tag_categories + [ - 'href', 'title', 'url', 'cover', 'cover_thumb', 'slug', 'cover_source_image', 'fragment_data'] + 'href', 'title', 'url', 'cover', 'cover_thumb', 'slug', 'cover_source_image'] def read(self, request, title_part=None, author_part=None, is_lektura=None, is_audiobook=None, after=None, before=None, count=None): @@ -314,6 +312,13 @@ class FilterBooksHandler(AnonymousBooksHandler): books = books.filter(media__type='mp3') else: books = books.exclude(media__type='mp3') + for key in request.GET: + if key in category_singular: + category = category_singular[key] + if category in book_tag_categories: + slugs = request.GET[key].split(',') + tags = Tag.objects.filter(category=category, slug__in=slugs) + books = Book.tagged.with_any(tags, books) return super(FilterBooksHandler, self).read(request, books=books, after=after, before=before, count=count)