remove use of sql direct for delete, just use import line as needed to avoid circular import
This commit is contained in:
8
loan.py
8
loan.py
@@ -90,11 +90,11 @@ def loan(id):
|
||||
loan = Loan.query.get(id)
|
||||
try:
|
||||
if 'delete' in request.form:
|
||||
from main import Book_Loan_Link
|
||||
|
||||
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
|
||||
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()
|
||||
Book_Loan_Link.query.filter(Loan.id==id).delete()
|
||||
Loan.query.filter(Loan.id==id).delete()
|
||||
if 'submit' in request.form:
|
||||
st.SetMessage( f"Successfully Updated Loan (id={id})" )
|
||||
loan.firstnames = request.form['firstnames']
|
||||
|
||||
Reference in New Issue
Block a user