fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
16fae9f
)
api: fix unlike
author
Jan Szejko
<janek37@gmail.com>
Thu, 9 Aug 2018 15:12:17 +0000
(17:12 +0200)
committer
Jan Szejko
<janek37@gmail.com>
Thu, 9 Aug 2018 15:12:17 +0000
(17:12 +0200)
src/api/handlers.py
patch
|
blob
|
history
diff --git
a/src/api/handlers.py
b/src/api/handlers.py
index
8d32873
..
af01337
100644
(file)
--- a/
src/api/handlers.py
+++ b/
src/api/handlers.py
@@
-745,13
+745,14
@@
class UserLikeHandler(BaseHandler):
return rc.NOT_FOUND
return {'likes': likes(request.user, book)}
return rc.NOT_FOUND
return {'likes': likes(request.user, book)}
- def create(self, request, slug
, action='like'
):
+ def create(self, request, slug):
if not request.user.is_authenticated():
return rc.FORBIDDEN
try:
book = Book.objects.get(slug=slug)
except Book.DoesNotExist:
return rc.NOT_FOUND
if not request.user.is_authenticated():
return rc.FORBIDDEN
try:
book = Book.objects.get(slug=slug)
except Book.DoesNotExist:
return rc.NOT_FOUND
+ action = request.GET.get('action', 'like')
if action == 'like':
book.like(request.user)
elif action == 'unlike':
if action == 'like':
book.like(request.user)
elif action == 'unlike':