Add household support: multi-household isolation, each with own admin and users, 38 tests
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user