fixed bug where when you remove a sub_book it left a whole in sub_book_num's, and rewrote to new sqlalchemy 2, all the direct sqls

This commit is contained in:
2023-06-11 11:23:48 +10:00
parent 4223b81641
commit 196f758372
3 changed files with 50 additions and 21 deletions

View File

@@ -90,9 +90,10 @@ def loan(id):
loan = Loan.query.get(id)
try:
if 'delete' in request.form:
st.SetMessage( f"Successfully deleted (id={loan.id}, who={loan.firsnames} {loan.surname})" )
st.SetMessage( f"Successfully deleted (id={loan.id}, who={loan.firstnames} {loan.surname})" )
# fall back to direct sql because loan.py is imported before Book_Loan_Link exists
db.engine.execute( f"delete from book_loan_link where loan_id = {loan.id}" )
with db.engine.connect() as conn:
conn.exec_driver_sql( f"delete from book_loan_link where loan_id = {loan.id}" )
loan = Loan.query.filter(Loan.id==id).delete()
if 'submit' in request.form:
st.SetMessage( f"Successfully Updated Loan (id={id})" )