TODO-2 completed, can remove a subbook from parent
This commit is contained in:
11
main.py
11
main.py
@@ -352,7 +352,15 @@ def subbooks_for_book(id):
|
|||||||
################################################################################
|
################################################################################
|
||||||
@app.route("/remove_subbook", methods=["POST"])
|
@app.route("/remove_subbook", methods=["POST"])
|
||||||
def remove_sub_book():
|
def remove_sub_book():
|
||||||
return redirect( '/book/{}'.format(request.form['rem_sub_parent_id']) )
|
print("DDP: ADD SQL HERE TO DO THE DELETE - try/except")
|
||||||
|
try:
|
||||||
|
db.engine.execute("delete from book_sub_book_link where book_id = {} and sub_book_id = {}".format( request.form['rem_sub_parent_id'], request.form['rem_sub_sub_book_id']) )
|
||||||
|
db.session.commit()
|
||||||
|
return redirect( '/book/{}'.format(request.form['rem_sub_parent_id']) )
|
||||||
|
except SQLAlchemyError as e:
|
||||||
|
st.SetAlert( "danger" )
|
||||||
|
st.SetMessage( e.orig )
|
||||||
|
return redirect( '/book/{}'.format(request.form['rem_sub_sub_book_id']) )
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# /book -> GET/POST -> creates a new book and when created, takes you back to
|
# /book -> GET/POST -> creates a new book and when created, takes you back to
|
||||||
@@ -438,7 +446,6 @@ def book(id):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
st.SetAlert( "danger" )
|
st.SetAlert( "danger" )
|
||||||
print("actual sql alchemy error")
|
|
||||||
st.SetMessage( e.orig )
|
st.SetMessage( e.orig )
|
||||||
return redirect( '/book/{}'.format(id) )
|
return redirect( '/book/{}'.format(id) )
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user