Fixed BUG-18 -> cannot find book
This commit is contained in:
3
BUGs
3
BUGs
@@ -1,5 +1,4 @@
|
|||||||
#### BUGS (next-18)
|
#### BUGS (next-19)
|
||||||
BUG-18: delete a book, then go to that URL and you get odd DB errors, rather than book not found
|
|
||||||
|
|
||||||
### DB/back-end
|
### DB/back-end
|
||||||
BUG-2: series does not deal with calcd_rating...
|
BUG-2: series does not deal with calcd_rating...
|
||||||
|
|||||||
9
main.py
9
main.py
@@ -439,13 +439,13 @@ def new_book():
|
|||||||
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 )
|
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 )
|
||||||
db.session.add(book)
|
db.session.add(book)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
# this is a sub-book we have added
|
# this is a sub-book we have added
|
||||||
if 'parent_id' in request.form:
|
if 'parent_id' in request.form:
|
||||||
db.engine.execute( "insert into book_sub_book_link ( book_id, sub_book_id, sub_book_num ) values ( {}, {}, (select COALESCE(MAX(sub_book_num),0)+1 from book_sub_book_link where book_id = {}) )".format( request.form['parent_id'], book.id, request.form['parent_id'] ) )
|
db.engine.execute( "insert into book_sub_book_link ( book_id, sub_book_id, sub_book_num ) values ( {}, {}, (select COALESCE(MAX(sub_book_num),0)+1 from book_sub_book_link where book_id = {}) )".format( request.form['parent_id'], book.id, request.form['parent_id'] ) )
|
||||||
parent=Book.query.get(request.form['parent_id'])
|
parent=Book.query.get(request.form['parent_id'])
|
||||||
if len(parent.series) > 0:
|
if len(parent.series) > 0:
|
||||||
# we have added a sub-book to something in a series
|
# we have added a sub-book to something in a series
|
||||||
# already, so add a bsl for the next book_num
|
# already, so add a bsl for the next book_num
|
||||||
for s in parent.bsl:
|
for s in parent.bsl:
|
||||||
db.engine.execute( "insert into book_series_link ( series_id, book_id, book_num ) values ( {}, {}, (select COALESCE(MAX(book_num),0)+1 from book_series_link where series_id={}) )".format( s.series_id, book.id, s.series_id ) )
|
db.engine.execute( "insert into book_series_link ( series_id, book_id, book_num ) values ( {}, {}, (select COALESCE(MAX(book_num),0)+1 from book_series_link where series_id={}) )".format( s.series_id, book.id, s.series_id ) )
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@@ -593,6 +593,11 @@ def book(id):
|
|||||||
st.SetMessage(message)
|
st.SetMessage(message)
|
||||||
else:
|
else:
|
||||||
book = Book.query.get(id)
|
book = Book.query.get(id)
|
||||||
|
if book == None:
|
||||||
|
st.SetAlert("danger")
|
||||||
|
st.SetMessage("Cannot find Book (id={})".format(id))
|
||||||
|
return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage())
|
||||||
|
|
||||||
book_form=BookForm(obj=book)
|
book_form=BookForm(obj=book)
|
||||||
|
|
||||||
author_list = GetAuthors()
|
author_list = GetAuthors()
|
||||||
|
|||||||
Reference in New Issue
Block a user