Add household support: multi-household isolation, each with own admin and users, 38 tests

This commit is contained in:
agentbox
2026-07-31 21:44:29 +00:00
parent d58828e0ef
commit c48cd265ca
10 changed files with 459 additions and 126 deletions
+3 -4
View File
@@ -10,7 +10,6 @@ from flask import (
url_for,
session,
flash,
jsonify,
)
from models import get_dashboard_data, upsert_response, ensure_meal_periods
@@ -42,6 +41,7 @@ def index():
@login_required
def dashboard():
today = date.today()
household_id = session["household_id"]
# Allow viewing other dates via query param
date_str = request.args.get("date")
@@ -51,7 +51,7 @@ def dashboard():
except ValueError:
flash("Invalid date format. Use YYYY-MM-DD.", "error")
data = get_dashboard_data(today)
data = get_dashboard_data(today, household_id)
return render_template(
"dashboard.html",
dashboard=data,
@@ -83,7 +83,6 @@ def respond():
flash("Invalid date.", "error")
return redirect(url_for("meals.dashboard"))
# Only allow responding to today (and not in the past)
if target_date < date.today():
flash("Cannot change responses for past dates.", "error")
return redirect(url_for("meals.dashboard"))
@@ -107,7 +106,7 @@ def history():
except ValueError:
target_date = date.today()
data = get_dashboard_data(target_date)
data = get_dashboard_data(target_date, session["household_id"])
return render_template(
"dashboard.html",
dashboard=data,