diff --git a/main.py b/main.py
index dd79452..77923b0 100644
--- a/main.py
+++ b/main.py
@@ -415,7 +415,7 @@ def new_book():
if len(parent.series) > 0:
print ("I think this means we have added a sub-book to something in a series already" )
for s in parent.bsl:
- db.engine.execute( "insert into book_series_link ( series_id, book_id, book_num ) values ( {}, {}, {} )".format( s.series_id, book.id, (s.book_num+1) ) )
+ 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()
st.SetMessage( "Created new Book ({})".format(book.title) )
cnt=1
diff --git a/templates/book.html b/templates/book.html
index a02db01..f36bb2b 100644
--- a/templates/book.html
+++ b/templates/book.html
@@ -66,7 +66,6 @@ function ConfirmRemoveThisSubs_ParentAndSubsFromSeries(pid,bid,rem)
Cancel Series change
`
- console.log(rem.length)
if( rem.length > 1 )
{
all='for ALL series'
@@ -94,7 +93,7 @@ function SeriesButPlus(num) {
}
function AddBookToSeries() {
- console.log("add Book to series")
+console.log("add Book to series")
// Read the Number from that DIV's ID (i.e: 3 from "series-div-3") -- could
// also be the filler (series-div-0), thats ok too
@@ -140,7 +139,7 @@ console.log( "reset buttons on last_div is=" + last_div.prop('id') )
}
function RemoveBookFromSeries(sid) {
- console.log("remove Book from Series: " + sid )
+console.log("remove Book from Series: " + sid )
$('#'+sid).remove()
var num = parseInt( sid.match(/\d+/g), 10 );
@@ -413,7 +412,6 @@ function AddAuthorToBook(num) {