fix BUG-25 by using ORM not db calls direct, could not see why they worked in DEV but not PROD with NO logs - only assume sqlachemy2 doesnt like the engine execute code I used instead
This commit is contained in:
22
main.py
22
main.py
@@ -774,27 +774,19 @@ def stats():
|
||||
def rem_books_from_loan(id):
|
||||
for field in request.form:
|
||||
rem_id=int(re.findall( '\d+', field )[0])
|
||||
try:
|
||||
with db.engine.connect() as conn:
|
||||
conn.exec_driver_sql( "delete from book_loan_link where book_id = {} and loan_id = {}".format( rem_id, id ))
|
||||
db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
st.SetAlert("danger")
|
||||
st.SetMessage("Failed to remove books from loan! -- {}".format( e.orig ))
|
||||
return jsonify(success=True)
|
||||
bll = Book_Loan_Link.query.filter(Book_Loan_Link.loan_id==id, Book_Loan_Link.book_id == rem_id ).one()
|
||||
db.session.delete(bll)
|
||||
db.session.commit()
|
||||
return jsonify(success=True)
|
||||
|
||||
@app.route("/add_books_to_loan/<id>", methods=["POST"])
|
||||
@login_required
|
||||
def add_books_to_loan(id):
|
||||
for field in request.form:
|
||||
add_id=int(re.findall( '\d+', field )[0])
|
||||
try:
|
||||
with db.engine.connect() as conn:
|
||||
conn.exec_driver_sql( "insert into book_loan_link (book_id, loan_id) values ( {}, {} )".format( add_id, id ))
|
||||
db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
st.SetAlert("danger")
|
||||
st.SetMessage("Failed to add books to loan! -- {}".format( e.orig ))
|
||||
bll = Book_Loan_Link( loan_id=id, book_id=add_id )
|
||||
db.session.add(bll)
|
||||
db.session.commit()
|
||||
return jsonify(success=True)
|
||||
|
||||
@app.route("/rem_parent_books_from_series/<pid>", methods=["POST"])
|
||||
|
||||
Reference in New Issue
Block a user