def set_current_page(request):
"""
Changes current readed page for book of the user.
"""
user = get_object_or_404(TheUser, auth_token=request.data.get('user_token'))
book = get_object_or_404(Book, id=request.data.get('book_id'))
current_page = request.data.get('current_page')
if not isinstance(current_page, int):
return Response({'status': 400,
'detail': 'current page not a number',
'data': {}}, status=400)
added_book = AddedBook.objects.get(id_book=book, id_user=user)
added_book.last_page = current_page
added_book.save()
logger.info("User '{}' on book with id: '{}' changed page to: '{}'."
.format(user, book.id, current_page))
return Response({'status': 200,
'detail': 'successful',
'data': {}})
评论列表
文章目录