moved display message to base.html, should have done this from the beginning (doh), and then fixed deletion errors/redirections to be moe sensible

This commit is contained in:
2020-12-26 22:19:05 +11:00
parent 80719a3657
commit de860a1319
7 changed files with 19 additions and 32 deletions

14
main.py
View File

@@ -416,10 +416,18 @@ def book(id):
st.SetMessage( "This is a parent book, cannot delete it without deleting sub books first" )
return redirect( '/book/{}'.format(book.id) )
else:
st.SetMessage("WARNING: Deleting being tested at present.<br>")
st.AppendMessage("Deleted {}".format(book.title) )
pid = 0
if len(book.parent) > 0:
pid = book.parent[0].id
db.session.delete(book)
db.session.commit()
st.SetAlert("warning")
st.SetMessage("WARNING: Deleting being tested at present")
if pid > 0:
return redirect( '/book/{}'.format(pid) )
else:
return redirect( '/' )
elif book_form.validate():
book = Book.query.get(id)
book.title = request.form['title']
@@ -458,7 +466,7 @@ def book(id):
## TODO:
# what about series?, subbooks?, loan?, etc.
db.session.commit()
st.SetMesage( "Successfully Updated Book (id={})".format(id) )
st.SetMessage( "Successfully Updated Book (id={})".format(id) )
else:
st.SetAlert("danger")
message="Failed to update Book (id={})".format(id)
@@ -506,7 +514,7 @@ def stats():
@app.route("/", methods=["GET"])
def main_page():
return render_template("base.html")
return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage())
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)