def Book_delete(id: int): if not auth.is_authorized(): return redirect('/login') book = Books.query.filter_by(id=id).first() if book.user.id != auth.get_user().id: abort(403) Books.delete(book) return redirect('/books')
def delete(self, id): if not self._auth.is_authorized(): abort(401) books = Books.query.filter_by(id=id).first() if books.user_id != self._auth.get_user().id: abort(403) Books.delete(books) return jsonify({"deleted": True})
def del_book(id): exists = Books.select().filter(id=id).exists() if not exists: return jsonify( {"message": "Can't find book with id - `{id}`".format(id=id)}), 404 Books.delete().where(Books.id == id).execute() return jsonify({}), 204
def ship(): user = auth.get_logged_in_user() #book = get_object_or_404(Books, Books.user == user, Books.id) if request.method == "POST": book_id = request.form["book_id"] b = Books.delete().where(Books.ownership == user and Books.id == book_id) b.execute() return render_template("shipped.html") else: print "wtf" return redirect(url_for("dashboard"))