Beispiel #1
0
 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')
Beispiel #2
0
 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})
Beispiel #3
0
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
Beispiel #4
0
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"))