diff --git a/main.py b/main.py index 366ccfd..a7d0a63 100644 --- a/main.py +++ b/main.py @@ -156,7 +156,7 @@ def book(id): print( "child book details:" ) print( book.child_ref ) - return render_template("books.html", books=book_s, subs=sub_book ) + return render_template("book.html", books=book_s, subs=sub_book ) @app.route("/authors", methods=["GET"]) def authors(): @@ -167,20 +167,26 @@ def authors(): def author(id): ### DDP: should this be request.form or request.values? author_form = AuthorForm(request.form) - print("we are here") if request.method == 'POST' and author_form.validate(): - print("we are posting") id = request.form['id'] author = Author.query.get(id) - author.firstnames = request.form['firstnames'] - author.surname = request.form['surname'] - db.session.commit() - message="Successfully Updated Author (id={})".format(id) + try: + request.form['submit'] + except: + message="Sorry, Deleting unsupported at present" + alert="Danger" + else: + print( "seems to be saving" ) + author.firstnames = request.form['firstnames'] + author.surname = request.form['surname'] + db.session.commit() + message="Successfully Updated Author (id={})".format(id) + alert="Success" else: author = Author.query.get(id) author_form = AuthorForm(request.values, obj=author) message="" - return render_template("author.html", author=author, message=message, author_form=author_form) + return render_template("author.html", author=author, alert=alert, message=message, author_form=author_form) @app.route("/", methods=["GET"]) def main_page():