From a806a5b19ac0b8b18d88511b49cf4399f38388c2 Mon Sep 17 00:00:00 2001 From: Darek Date: Sun, 12 Apr 2026 15:31:23 -0500 Subject: [PATCH] Add storage location field to bulk add form --- app.py | 21 ++++++++++++++------- templates/battery_add.html | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index b2272dc..f89e243 100644 --- a/app.py +++ b/app.py @@ -59,23 +59,30 @@ def create_app(config_object="config"): except ValueError: return None - size = f.get("size", "").strip() or None - chemistry = f.get("chemistry", "").strip() or None - capacity_mah = _int("capacity_mah") - purchase_date = f.get("purchase_date", "").strip() or None + size = f.get("size", "").strip() or None + chemistry = f.get("chemistry", "").strip() or None + capacity_mah = _int("capacity_mah") + purchase_date = f.get("purchase_date", "").strip() or None + storage_location = f.get("storage_location", "").strip() or None existing = db.query(func.count(Battery.id)).filter_by(brand=brand).scalar() for i in range(count): label = f"{brand} {existing + i + 1:03d}" db.add(Battery(label=label, brand=brand, status="available", notes=notes, - size=size, chemistry=chemistry, - capacity_mah=capacity_mah, purchase_date=purchase_date)) + size=size, chemistry=chemistry, capacity_mah=capacity_mah, + purchase_date=purchase_date, storage_location=storage_location)) db.commit() flash(f"Added {count} {brand} batter{'y' if count == 1 else 'ies'}.", "success") return redirect(url_for("dashboard")) brands = [r[0] for r in db.query(Battery.brand).distinct().order_by(Battery.brand).all()] - return render_template("battery_add.html", form_count=1, brands=brands) + storage_locations = [ + r[0] for r in db.query(Battery.storage_location) + .filter(Battery.storage_location.isnot(None)) + .distinct().order_by(Battery.storage_location).all() + ] + return render_template("battery_add.html", form_count=1, brands=brands, + storage_locations=storage_locations) # ------------------------------------------------------------------ # # Battery — detail diff --git a/templates/battery_add.html b/templates/battery_add.html index 7ea8f73..4349394 100644 --- a/templates/battery_add.html +++ b/templates/battery_add.html @@ -68,6 +68,20 @@ +
+ + + +
+