feat(shopping): editable quantity field per item
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 26s
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 26s
Each item row now has an editable qty input showing the planned amount (e.g. "6 × ½ kg"). Changes are auto-saved via debounce to the prices table and highlighted in accent color when modified from the default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
13
app.py
13
app.py
@@ -103,7 +103,7 @@ def get_db():
|
||||
def init_db():
|
||||
with get_db() as c:
|
||||
c.execute("""CREATE TABLE IF NOT EXISTS prices (
|
||||
key TEXT PRIMARY KEY, price REAL, checked INT DEFAULT 0, updated TEXT)""")
|
||||
key TEXT PRIMARY KEY, price REAL, checked INT DEFAULT 0, qty TEXT, updated TEXT)""")
|
||||
c.execute("""CREATE TABLE IF NOT EXISTS extras (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT, section_key TEXT, price REAL,
|
||||
@@ -115,6 +115,10 @@ def init_db():
|
||||
c.execute("ALTER TABLE extras ADD COLUMN section_key TEXT")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
c.execute("ALTER TABLE prices ADD COLUMN qty TEXT")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@@ -136,13 +140,14 @@ def save_price():
|
||||
key = d.get('key')
|
||||
price = d.get('price')
|
||||
checked = int(d.get('checked', 0))
|
||||
qty = d.get('qty') or None
|
||||
if not key:
|
||||
return jsonify(error='missing key'), 400
|
||||
with get_db() as c:
|
||||
c.execute("""INSERT INTO prices(key,price,checked,updated) VALUES(?,?,?,?)
|
||||
c.execute("""INSERT INTO prices(key,price,checked,qty,updated) VALUES(?,?,?,?,?)
|
||||
ON CONFLICT(key) DO UPDATE SET price=excluded.price,
|
||||
checked=excluded.checked, updated=excluded.updated""",
|
||||
(key, price, checked, datetime.now().isoformat()))
|
||||
checked=excluded.checked, qty=excluded.qty, updated=excluded.updated""",
|
||||
(key, price, checked, qty, datetime.now().isoformat()))
|
||||
return jsonify(ok=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user