fixed BUG-8, no genres for a sub book addition loses parent details

This commit is contained in:
2021-01-03 12:08:19 +11:00
parent ff45513c7d
commit cc13ecfc87
3 changed files with 9 additions and 3 deletions

View File

@@ -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 = "{}<br>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() )