swap order of books in series works - still has debugs, and only works on current series, e.g. if you are in a series in a series, it will need you to manually do the same move in both series - I think I wont fix this bit, but we will see
This commit is contained in:
22
main.py
22
main.py
@@ -162,8 +162,28 @@ def books_for_loan(id):
|
||||
books = Book.query.join(Book_Loan_Link).filter(Book_Loan_Link.loan_id==id).order_by(Book.id).all()
|
||||
return render_template("books_for_loan.html", books=books)
|
||||
|
||||
@app.route("/books_for_series/<id>", methods=["GET"])
|
||||
@app.route("/books_for_series/<id>", methods=["GET", "POST"])
|
||||
def books_for_series(id):
|
||||
if request.method == 'POST':
|
||||
if 'move_button' in request.form:
|
||||
print( 'we are moving a book up or down in series, we pressed: ' + request.form['move_button'] )
|
||||
dir, bid = request.form['move_button'].split('-')
|
||||
print( "dir="+dir)
|
||||
print( "bid="+bid)
|
||||
print( "id="+id)
|
||||
bsl1=Book_Series_Link.query.filter(Book_Series_Link.series_id==id, Book_Series_Link.book_id==bid).all()
|
||||
print( bsl1[0].book_num )
|
||||
if dir == "up":
|
||||
other_bn=bsl1[0].book_num-1
|
||||
else:
|
||||
other_bn=bsl1[0].book_num+1
|
||||
bsl2=Book_Series_Link.query.filter(Book_Series_Link.series_id==id, Book_Series_Link.book_num==other_bn).all()
|
||||
print( bsl1[0].book_id )
|
||||
print( "swap with book: " )
|
||||
print( bsl2[0].book_id )
|
||||
bsl2[0].book_num=bsl1[0].book_num
|
||||
bsl1[0].book_num=other_bn
|
||||
db.session.commit()
|
||||
books = Book.query.join(Book_Series_Link).filter(Book_Series_Link.series_id==id).order_by(Book.id).all()
|
||||
series = Series.query.get(id)
|
||||
return render_template("books_for_series.html", books=books, series=series)
|
||||
|
||||
Reference in New Issue
Block a user