From cc13ecfc87cdf09b55a485f358d2f87e6a9b75b8 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 3 Jan 2021 12:08:19 +1100 Subject: [PATCH] fixed BUG-8, no genres for a sub book addition loses parent details --- BUGs | 2 -- main.py | 9 ++++++++- templates/book.html | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BUGs b/BUGs index 6dfbe06..ca2a8f5 100644 --- a/BUGs +++ b/BUGs @@ -8,5 +8,3 @@ BUG-6: author,series, etc. do not have explicit ordering like sub-books... sort - add/remove authors, and after save they are ordered by author.id, not order of addition (prob. needs book_author_link to have an auth_num) BUG-7: if you remove a series from a book, it won't appear in the series drop-down if it is the first 'missing' book in that series -- either reset the list, or show all series always? - -BUG-8: if you add a sub-book, then fail to validate (say no genre), then it takes you back, you click a genre (BUT it has lost th eparent association), so it adds a book, not a sub-book diff --git a/main.py b/main.py index 4cd44b5..997fe78 100644 --- a/main.py +++ b/main.py @@ -385,6 +385,7 @@ def new_book(): parent=request.form['add_sub_parent_id'] book = Book.query.get(parent) bb=QuickParentBook() + bb.parent=[] bb.parent.append( { 'id': parent, 'title': book.title } ) form.publisher.default = book.publisher form.owned.default = book.owned @@ -418,7 +419,13 @@ def new_book(): message = "{}
genre=book has to have a genre selected".format( message ) print( "ERROR: Failed to create book: {}".format(message) ) book = Book( title=request.form["title"], owned=request.form['owned'], covertype=request.form['covertype'], condition=request.form['condition'], publisher=request.form['publisher'], year_published=request.form['year_published'], rating=request.form['rating'], notes=request.form['notes'], blurb=request.form['blurb'], genre=book_genres, author=book_authors ) - return render_template("book.html", page_title=page_title, b=None, books=book, book_form=form, author_list=author_list, genre_list=genre_list, alert=alert, message=message, poss_series_list=ListOfSeriesWithMissingBooks() ) + if 'parent_id' in request.form: + bb=QuickParentBook() + bb.parent=[] + bb.parent.append( { 'id': request.form['parent_id'], 'title': request.form['parent_title'] } ) + else: + bb=None + return render_template("book.html", page_title=page_title, b=bb, books=book, book_form=form, author_list=author_list, genre_list=genre_list, alert=alert, message=message, poss_series_list=ListOfSeriesWithMissingBooks() ) else: return render_template("book.html", page_title=page_title, b=None, books=None, book_form=form, author_list=author_list, genre_list=genre_list, alert="success", message="", poss_series_list=ListOfSeriesWithMissingBooks() ) diff --git a/templates/book.html b/templates/book.html index 0957ccc..300275e 100644 --- a/templates/book.html +++ b/templates/book.html @@ -139,6 +139,7 @@ function AddAuthorToBook(num) { + {% endif %} {% for key in keys %}