remove 'before' support in api
authorJan Szejko <janek37@gmail.com>
Fri, 21 Sep 2018 10:26:00 +0000 (12:26 +0200)
committerJan Szejko <janek37@gmail.com>
Fri, 21 Sep 2018 10:26:00 +0000 (12:26 +0200)
src/api/handlers.py
src/api/urls.py

index 2a12ec4..3aefcff 100644 (file)
@@ -204,7 +204,7 @@ class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
     @piwik_track
     def read(self, request, tags=None, top_level=False, audiobooks=False, daisy=False, pk=None,
              recommended=False, newest=False, books=None,
     @piwik_track
     def read(self, request, tags=None, top_level=False, audiobooks=False, daisy=False, pk=None,
              recommended=False, newest=False, books=None,
-             after=None, before=None, count=None):
+             after=None, count=None):
         """ Lists all books with given tags.
 
         :param tags: filtering tags; should be a path of categories
         """ Lists all books with given tags.
 
         :param tags: filtering tags; should be a path of categories
@@ -226,8 +226,6 @@ class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
 
         if 'after' in request.GET:
             after = request.GET['after']
 
         if 'after' in request.GET:
             after = request.GET['after']
-        if 'before' in request.GET:
-            before = request.GET['before']
         if 'count' in request.GET:
             count = request.GET['count']
 
         if 'count' in request.GET:
             count = request.GET['count']
 
@@ -252,20 +250,16 @@ class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
         if newest:
             books = books.order_by('-created_at')
 
         if newest:
             books = books.order_by('-created_at')
 
+        # beznadzieja
         if after:
             books = books.filter(slug__gt=after)
         if after:
             books = books.filter(slug__gt=after)
-        if before:
-            books = books.filter(slug__lt=before)
 
         books = books.only('slug', 'title', 'cover', 'cover_thumb')
         for category in book_tag_categories:
             books = prefetch_relations(books, category)
 
         if count:
 
         books = books.only('slug', 'title', 'cover', 'cover_thumb')
         for category in book_tag_categories:
             books = prefetch_relations(books, category)
 
         if count:
-            if before:
-                books = list(reversed(books.order_by('-slug')[:count]))
-            else:
-                books = books[:count]
+            books = books[:count]
 
         return books
 
 
         return books
 
@@ -592,7 +586,6 @@ class TagsHandler(BaseHandler, TagDetails):
             return rc.NOT_FOUND
 
         after = request.GET.get('after')
             return rc.NOT_FOUND
 
         after = request.GET.get('after')
-        before = request.GET.get('before')
         count = request.GET.get('count')
 
         tags = Tag.objects.filter(category=category_sng).exclude(items=None).order_by('slug')
         count = request.GET.get('count')
 
         tags = Tag.objects.filter(category=category_sng).exclude(items=None).order_by('slug')
@@ -606,14 +599,9 @@ class TagsHandler(BaseHandler, TagDetails):
 
         if after:
             tags = tags.filter(slug__gt=after)
 
         if after:
             tags = tags.filter(slug__gt=after)
-        if before:
-            tags = tags.filter(slug__lt=before)
 
         if count:
 
         if count:
-            if before:
-                tags = list(reversed(tags.order_by('-slug')[:count]))
-            else:
-                tags = tags[:count]
+            tags = tags[:count]
 
         return tags
 
 
         return tags
 
index 9cec9b8..bb0c1f4 100644 (file)
@@ -69,7 +69,7 @@ blog_resource = Resource(handler=handlers.BlogEntryHandler)
 
 
 tags_re = r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){0,6})'
 
 
 tags_re = r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){0,6})'
-paginate_re = r'(?:before/(?P<before>[a-z0-9-]+)/)?(?:after/(?P<after>[a-z0-9-]+)/)?(?:count/(?P<count>[0-9]+)/)?$'
+paginate_re = r'(?:after/(?P<after>[a-z0-9-]+)/)?(?:count/(?P<count>[0-9]+)/)?$'
 
 
 @ssi_included
 
 
 @ssi_included