premium info in user data api
authorJan Szejko <janek37@gmail.com>
Thu, 23 Aug 2018 15:04:07 +0000 (17:04 +0200)
committerJan Szejko <janek37@gmail.com>
Thu, 23 Aug 2018 15:04:07 +0000 (17:04 +0200)
src/api/handlers.py

index d050f0f..0814fd4 100644 (file)
@@ -669,14 +669,14 @@ class PictureHandler(BaseHandler):
 
 class UserDataHandler(BaseHandler):
     model = BookUserData
-    fields = ('state', 'username')
+    fields = ('state', 'username', 'premium')
     allowed_methods = ('GET', 'POST')
 
     def read(self, request, slug=None):
         if not request.user.is_authenticated():
             return rc.FORBIDDEN
         if slug is None:
-            return {'username': request.user.username}
+            return {'username': request.user.username, 'premium': is_subscribed(request.user)}
         try:
             book = Book.objects.get(slug=slug)
         except Book.DoesNotExist: