def book_delete(book_id): if not current_user.is_admin: abort(403) b = Book.get(book_id) if not b: abort(404) b.delete() return redirect(url_for("admin_public"))
def book_share(book_id): b = Book.get(book_id) if not b: abort(404) if b.added_by_login != current_user.login: abort(403) b.is_public = not b.is_public b.save() return redirect(url_for("main"))
def book_remove(book_id): b = Book.get(book_id) if not b: abort(404) if not b.is_public: abort(403) if current_user.has_book(b): current_user.books.remove(b) current_user.save() return redirect(url_for("main"))
def book_get(book_id): b = Book.get(book_id) if not b: abort(404) if not b.is_public: abort(403) if not current_user.has_book(b): current_user.books.append(b) current_user.save() return redirect(url_for("public"))