fixed button ordering, which also fixed bug with page_title for book.html not being used

This commit is contained in:
2020-12-31 12:03:29 +11:00
parent 08f1550068
commit 5a92f967be
2 changed files with 11 additions and 6 deletions

View File

@@ -353,6 +353,7 @@ class QuickParentBook:
@app.route("/book", methods=["GET", "POST"])
def new_book():
form = BookForm(request.form)
page_title='Create new Book'
author_list = GetAuthors()
genre_list = GetGenres()
book_authors=[]
@@ -401,14 +402,15 @@ 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='Create new Book', b=None, books=book, book_form=form, author_list=author_list, genre_list=genre_list, alert=alert, message=message, poss_series_list=ListOfSeriesWithMissingBooks() )
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() )
else:
return render_template("book.html", page_title='Create new Book', b=None, books=None, book_form=form, author_list=author_list, genre_list=genre_list, alert="success", message="", poss_series_list=ListOfSeriesWithMissingBooks() )
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() )
@app.route("/book/<id>", methods=["GET", "POST"])
def book(id):
book_form = BookForm(request.form)
page_title='Edit Book'
if request.method == 'POST':
if 'delete' in request.form:
book = Book.query.get(id)
@@ -497,7 +499,7 @@ def book(id):
genre_list = GetGenres()
book_s = book_schema.dump(book)
return render_template("book.html", b=book, books=book_s, book_form=book_form, author_list=author_list, genre_list=genre_list, alert=st.GetAlert(), message=st.GetMessage(), poss_series_list=ListOfSeriesWithMissingBooks() )
return render_template("book.html", b=book, books=book_s, book_form=book_form, author_list=author_list, genre_list=genre_list, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage(), poss_series_list=ListOfSeriesWithMissingBooks() )
def GetCount( what, where ):
st="select count(id) as count from book where "

View File

@@ -125,6 +125,7 @@ function AddAuthorToBook(num) {
{% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
<div class="container-fluid">
<div class="form-row col-lg-10"><h3 class="offset-lg-2">{{page_title}}</h3></div>
<div class="row">
<form role="form" class="form col-lg-10" action="" method="POST">
{{ book_form.id }}
@@ -286,13 +287,15 @@ function AddAuthorToBook(num) {
<div id="spacer"><br></div>
<div class="form-row">
<div class="form-row col mx-0">
{{ book_form.delete( class="btn btn-outline-danger offset-lg-2 col-lg-2" )}}
{{ book_form.submit( class="btn btn-primary col-lg-2" )}}
{{ book_form.submit( class="btn btn-primary offset-lg-2 col-lg-2" )}}
{% if 'Edit' in page_title %}
{{ book_form.delete( class="btn btn-outline-danger col-lg-2" )}}
{% endif %}
</div class="form-row">
</div class="form-row">
{{ hiddens.txt|safe }}
</form>
{% if b.parent|length == 0 %}
{% if b.parent|length == 0 and 'Edit' in page_title %}
<form role="form" class="form col-lg-10" action="{{url_for('new_book')}}" method="POST">
<input type="hidden" name="add_sub_parent_id" value="{{books.id}}">
{{ book_form.add_sub( class="btn btn-outline-success offset-lg-2 col-lg-2" )}}