From: Jan Szejko Date: Fri, 8 Dec 2017 13:43:28 +0000 (+0100) Subject: filter by tags X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/187d054620e6e005bed835fbdcb34a0098ffe98e?ds=inline;hp=-c filter by tags --- 187d054620e6e005bed835fbdcb34a0098ffe98e diff --git a/src/api/handlers.py b/src/api/handlers.py index b8eec2f4b..97b82fc7d 100644 --- a/src/api/handlers.py +++ b/src/api/handlers.py @@ -312,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)