table of contents only for custom PDF (for now)
[wolnelektury.git] / src / api / handlers.py
index 2e847c5..eb18e05 100644 (file)
@@ -19,8 +19,8 @@ from api.models import BookUserData
 from catalogue.forms import BookImportForm
 from catalogue.models import Book, Tag, BookMedia, Fragment, Collection
 from catalogue.models.tag import prefetch_relations
-from catalogue.utils import is_subscribed
 from librarian.cover import WLCover
+from paypal.rest import user_is_subscribed
 from picture.models import Picture
 from picture.forms import PictureImportForm
 from social.utils import likes
@@ -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',
@@ -330,7 +330,7 @@ class BooksHandler(BookDetailHandler):
 
 class EpubHandler(BookDetailHandler):
     def read(self, request, slug):
-        if not is_subscribed(request.user):
+        if not user_is_subscribed(request.user):
             return rc.FORBIDDEN
         try:
             book = Book.objects.get(slug=slug)
@@ -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)
@@ -733,7 +730,7 @@ class UserDataHandler(BaseHandler):
         if not request.user.is_authenticated():
             return rc.FORBIDDEN
         if slug is None:
-            return {'username': request.user.username, 'premium': is_subscribed(request.user)}
+            return {'username': request.user.username, 'premium': user_is_subscribed(request.user)}
         try:
             book = Book.objects.get(slug=slug)
         except Book.DoesNotExist: