BUG-13 delete loan fails with foreign key issues, all fixed

This commit is contained in:
2021-01-05 11:18:53 +11:00
parent 2028266ff7
commit 0ac5684f17
2 changed files with 2 additions and 1 deletions

1
BUGs
View File

@@ -3,7 +3,6 @@
### DB/back-end
BUG-2: series does not deal with calcd_rating...
- (on edit could, recalc as a catch-all, and obviously if we change a single book's rating, we should re-calc)
BUG-13: deleting loan fails with book_loan_link data still existing
### UI not updating after DB change:
BUG-3: alter a condition, covertype, etc. and its not in drop-down list (even though db look via index is correct, e.g books.html shows updated covertype)

View File

@@ -87,6 +87,8 @@ def loan(id):
try:
if 'delete' in request.form:
st.SetMessage("Successfully deleted (id={}, who={} {})".format( loan.id, loan.firstnames, loan.surname ) )
# fall back to direct sql because loan.py is imported before Book_Loan_Link exists
db.engine.execute("delete from book_loan_link where loan_id = {}".format( loan.id ))
loan = Loan.query.filter(Loan.id==id).delete()
if 'submit' in request.form:
st.SetMessage("Successfully Updated Loan (id={})".format(id) )