From 0ac5684f17c749986ab5f735936b890a59bd8c51 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 5 Jan 2021 11:18:53 +1100 Subject: [PATCH] BUG-13 delete loan fails with foreign key issues, all fixed --- BUGs | 1 - loan.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BUGs b/BUGs index 2929721..02a6cac 100644 --- a/BUGs +++ b/BUGs @@ -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) diff --git a/loan.py b/loan.py index 5f06cfa..d054cc8 100644 --- a/loan.py +++ b/loan.py @@ -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) )