read_book_views.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Plamber 作者: OlegKlimenko 项目源码 文件源码
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': {}})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号