Example #1
0
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"))
Example #2
0
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"))