def post(self): """Add a book to the authenticated user's reading list. :param-json int book_id: ID of the book to add. """ book = self._get_book_from_request() current_user.add_to_reading_list(book) current_user.save() return { 'result': serialize_book(book).data, 'user': serialize_user(current_user._get_current_object()).data, }, http.OK
def put(self): """Toggle the ``read`` status of a book. :param-json int book_id: ID of the book to modify. """ book = self._get_book_from_request() current_user.toggle_read(book) current_user.save() has_read = current_user.has_read(book) return { 'result': serialize_book(book, extra={'read': has_read}).data, 'user': serialize_user(current_user._get_current_object()).data, }, http.OK