From 187d054620e6e005bed835fbdcb34a0098ffe98e Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 8 Dec 2017 14:43:28 +0100 Subject: [PATCH] filter by tags --- src/api/handlers.py | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- 2.20.1