diff --git a/main.py b/main.py index fbbda5e..9620cc7 100644 --- a/main.py +++ b/main.py @@ -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.
") + 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) diff --git a/templates/authors.html b/templates/authors.html index e638a71..fd5f9fd 100644 --- a/templates/authors.html +++ b/templates/authors.html @@ -2,12 +2,6 @@ {% block main_content %}

Show All Authors

-{% if message|length %} -
- {{message}} - {{ ClearStatus() }} -
-{% endif %} diff --git a/templates/base.html b/templates/base.html index 6ea45e7..508e675 100644 --- a/templates/base.html +++ b/templates/base.html @@ -75,7 +75,14 @@ - {% block main_content %}{% endblock main_content %} + {% if message|length %} +
+ {{message|safe}} + {{ ClearStatus() }} +
+ {% endif %} + {% block main_content %} + {% endblock main_content %} diff --git a/templates/book.html b/templates/book.html index 036875d..87742ee 100644 --- a/templates/book.html +++ b/templates/book.html @@ -125,11 +125,6 @@ function AddAuthorToBook(num) { {% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
- {% if message|length %} -
- {{message|safe}} -
- {% endif %}
{{ book_form.id }} diff --git a/templates/loans.html b/templates/loans.html index f748470..3d3d209 100644 --- a/templates/loans.html +++ b/templates/loans.html @@ -2,12 +2,6 @@ {% block main_content %}

Loans

-{% if message|length %} -
- {{message}} - {{ ClearStatus() }} -
-{% endif %}
SurnameFirstname(s)
diff --git a/templates/series.html b/templates/series.html index 8eba1d9..600102f 100644 --- a/templates/series.html +++ b/templates/series.html @@ -7,11 +7,6 @@

Books in Series

{% endif %} - {% if message|length %} -
- {{message}} -
- {% endif %}
diff --git a/templates/show_id_name.html b/templates/show_id_name.html index 04a458a..24acad2 100644 --- a/templates/show_id_name.html +++ b/templates/show_id_name.html @@ -2,12 +2,6 @@ {% block main_content %}

{{page_title}}

-{% if message|length %} -
- {{message}} - {{ ClearStatus() }} -
-{% endif %}
SurnameFirstname(s)Date LentContact Details
Name