X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/cfbd4683aa50fb51882aa0ab825492b2dd49b142..481c75133987a510db34b0950b6861962aa2aaab:/src/api/handlers.py?ds=sidebyside diff --git a/src/api/handlers.py b/src/api/handlers.py index cee41f48a..d32981e04 100644 --- a/src/api/handlers.py +++ b/src/api/handlers.py @@ -33,7 +33,7 @@ from . import emitters # Register our emitters API_BASE = WL_BASE = MEDIA_BASE = lazy( lambda: u'https://' + Site.objects.get_current().domain, unicode)() -SORT_KEY_SEP = ',' +SORT_KEY_SEP = '$' category_singular = { 'authors': 'author', @@ -179,7 +179,7 @@ class BookDetails(object): try: author, title, book_id = after.split(SORT_KEY_SEP) except ValueError: - return [] + return Book.objects.none() return books.filter(Q(sort_key_author__gt=author) | (Q(sort_key_author=author) & Q(sort_key__gt=title)) | (Q(sort_key_author=author) & Q(sort_key=title) & Q(id__gt=int(book_id)))) @@ -378,16 +378,13 @@ class AnonFilterBooksHandler(AnonymousBooksHandler): return None def read(self, request): + key_sep = '$' search_string = request.GET.get('search') is_lektura = self.parse_bool(request.GET.get('lektura')) is_audiobook = self.parse_bool(request.GET.get('audiobook')) preview = self.parse_bool(request.GET.get('preview')) new_api = request.GET.get('new_api') - if new_api: - key_sep = ',' - else: - key_sep = '$' after = request.GET.get('after') count = int(request.GET.get('count', 50)) books = self.order_books(Book.objects.distinct(), new_api)