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/migrations/0003_pantryitem_state.py | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 kitchen/migrations/0003_pantryitem_state.py (limited to 'kitchen/migrations/0003_pantryitem_state.py') diff --git a/kitchen/migrations/0003_pantryitem_state.py b/kitchen/migrations/0003_pantryitem_state.py new file mode 100644 index 0000000..a380a39 --- /dev/null +++ b/kitchen/migrations/0003_pantryitem_state.py @@ -0,0 +1,42 @@ +from django.db import migrations, models + + +def backfill_state(apps, schema_editor): + """Items at quantity 0 are 'out'; everything else is 'in' (the field default).""" + PantryItem = apps.get_model("kitchen", "PantryItem") + PantryItem.objects.filter(quantity=0).update(state="out") + + +class Migration(migrations.Migration): + + dependencies = [ + ("kitchen", "0002_add_rating_and_preferences"), + ] + + operations = [ + migrations.AddField( + model_name="pantryitem", + name="state", + field=models.CharField( + choices=[("in", "In stock"), ("low", "Running low"), ("out", "Out")], + default="in", + max_length=10, + ), + ), + # Runs while quantity is still a Decimal column — 0 matches fine. + migrations.RunPython(backfill_state, migrations.RunPython.noop), + migrations.AlterField( + model_name="pantryitem", + name="quantity", + field=models.PositiveIntegerField( + blank=True, + help_text="Optional rough count; In/Low/Out is the primary signal", + null=True, + ), + ), + migrations.AlterField( + model_name="pantryitem", + name="unit", + field=models.CharField(blank=True, max_length=20), + ), + ] -- cgit v1.2.3