From b5e9c41cfdca8ca813bee12f9dbb81aa01e1abea Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 1 Dec 2020 20:39:40 +1100 Subject: [PATCH] update BUGs and README, to show issues with saving book... Many fields now save, but still some bugged or not tried --- BUGs | 4 ++++ README | 1 + main.py | 28 +++++++++++++++++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/BUGs b/BUGs index 891f8ed..e8d59ba 100644 --- a/BUGs +++ b/BUGs @@ -3,3 +3,7 @@ series does not deal with calcd_rating... alter a condition, covertype, etc. and its not in drop-down list (even though db look via index is correct, e.g books.html shows updated covertype) +book form is not validating (year published) +save book, notes/forms not sticking +tried publisher, firstly the has id="publisher", but not +name="publisher", so request.form does not have field publisher, hand-hacking that and then int/str mismatch... I think need to read up on how to take select 'value' as the int value of the chosen option diff --git a/README b/README index 2819085..cb5e477 100644 --- a/README +++ b/README @@ -26,6 +26,7 @@ python3 main.py ### TODO: - need to save a book + - still missing author, publisher, genre, notes, blurb. not sure about series/loan/subbook, etc. - need to create all classes (green + button) - need to delete all classes (and watch for referential integrity) - need to delete 1 book from sub_book, series, loan diff --git a/main.py b/main.py index 657b0ce..d97def8 100644 --- a/main.py +++ b/main.py @@ -338,21 +338,31 @@ def book(id): message="Sorry, Deleting unsupported at present" else: book.title = request.form['title'] + book.owned = request.form['owned'] + book.covertype = request.form['covertype'] + book.condition = request.form['condition'] + book.year_published = request.form['year_published'] + book.rating = request.form['rating'] + book.notes = request.form['notes'] + book.blurb = request.form['blurb'] + ## TODO: + # process author, genre, publisher & series?, subbooks?, loan?, etc. db.session.commit() message="Successfully Updated Book (id={})".format(id) + else: + book_form=BookForm(request.form) + # set defaults for drop-down's based on this book + book_form.condition.default = book.condition + book_form.covertype.default = book.covertype + book_form.owned.default = book.owned + book_form.rating.default = book.rating + book_form.process() - book_s = book_schema.dump(book) - - book_form=BookForm(request.form) - # set defaults for drop-down's based on this book - book_form.condition.default = book.condition - book_form.covertype.default = book.covertype - book_form.owned.default = book.owned - book_form.rating.default = book.rating - book_form.process() author_list = GetAuthors() genre_list = GetGenres() publisher_list = GetPublishers() + + book_s = book_schema.dump(book) return render_template("book.html", b=book, books=book_s, book_form=book_form, author_list=author_list, publisher_list=publisher_list, genre_list=genre_list, alert=alert, message=message ) @app.route("/", methods=["GET"])