From 0aabf50834a31ff4ae9f8fd58639e444a449110b Mon Sep 17 00:00:00 2001 From: Tom Flux Date: Tue, 23 Jun 2026 19:55:16 +0100 Subject: Phase 1: mobile-first pantry redesign with In/Low/Out state Track presence (In/Low/Out) as the primary signal instead of exact quantities; quantity becomes an optional integer, unit optional too (migration 0003 backfills state from quantity: 0 -> out, else in). - Pantry rebuilt as a phone-first card list: colored state rail, segmented In/Low/Out switch (server-driven HTMX), greyed out-items, live summary counts. - Fast add: bottom add bar with type-ahead autocomplete, location picker, and quick-add chips for things you've run out of. - Per-item menu (move / set expiry / delete); expiry is now an optional quiet pill, never required. - New endpoints: pantry search + set-state; dropped the old edit-expiry/cancel flow and its partial. - Recipes matcher made presence-based (have-it beats have-enough); state added to admin. Tests cover state, add/restock, search, presence matching, and page rendering. Co-Authored-By: Claude Opus 4.8 --- kitchen/helpers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'kitchen/helpers.py') diff --git a/kitchen/helpers.py b/kitchen/helpers.py index a4be79c..7853fd7 100644 --- a/kitchen/helpers.py +++ b/kitchen/helpers.py @@ -25,10 +25,15 @@ def find_ingredient(name): def get_pantry_total(ingredient_id): - """Get total quantity of an ingredient across all pantry locations.""" + """Total quantity of an ingredient across all locations, excluding items + marked 'out'. Null quantities count as 0 (presence is tracked via state, + not this number — see the pantry redesign in plan.md).""" total = Decimal("0") - for item in PantryItem.objects.filter(ingredient_id=ingredient_id, quantity__gt=0): - total += item.quantity + for item in ( + PantryItem.objects.filter(ingredient_id=ingredient_id) + .exclude(state=PantryItem.State.OUT) + ): + total += Decimal(item.quantity or 0) return total -- cgit v1.2.3