From 921a0a6e4f7654e25fc241ac1904e6e81c830929 Mon Sep 17 00:00:00 2001 From: Daniel Rahamim Date: Fri, 15 Mar 2024 09:34:55 -0700 Subject: [PATCH] fix(checkouts): report existing checkouts (#139) --- src/invenflask/app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/invenflask/app.py b/src/invenflask/app.py index b2d35e8..fb85bb3 100644 --- a/src/invenflask/app.py +++ b/src/invenflask/app.py @@ -228,6 +228,15 @@ def checkout(): ).scalar() and accessory_id != '': flash('Accessory does not exist', "warning") return render_template('checkout.html') + if db.session.query(Checkout).filter(func.lower( + func.lower(Checkout.assetid)) == accessory_id.lower()).first(): + flash('Accessory already checked out no checkouts saved', "warning") + return render_template('checkout.html') + + if db.session.query(Checkout).filter(func.lower( + func.lower(Checkout.assetid)) == asset_id.lower()).first(): + flash('Asset already checked out no checkouts saved', "warning") + return render_template('checkout.html') else: try: