Add household support: multi-household isolation, each with own admin and users, 38 tests
This commit is contained in:
+2
-1
@@ -11,7 +11,8 @@
|
||||
<span class="brand">🍽 Meal Tracker</span>
|
||||
{% if session.user_id %}
|
||||
<div class="nav-right">
|
||||
<span class="nav-user">{{ session.username }}</span>
|
||||
<span class="nav-household">{{ session.household_name }}</span>
|
||||
<span class="nav-user">{{ session.username }}{% if session.is_admin %} (admin){% endif %}</span>
|
||||
<a class="btn btn-sm" href="{{ url_for('auth.logout') }}">Logout</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
+37
-1
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Register — Meal Tracker{% endblock %}
|
||||
{% block content %}
|
||||
<div class="form-card">
|
||||
<div class="form-card register-card">
|
||||
<h2>Create Account</h2>
|
||||
<form method="POST">
|
||||
<label for="username">Username</label>
|
||||
@@ -13,6 +13,42 @@
|
||||
<label for="confirm">Confirm Password</label>
|
||||
<input type="password" id="confirm" name="confirm" required>
|
||||
|
||||
<fieldset class="household-section">
|
||||
<legend>Household</legend>
|
||||
|
||||
<label class="radio-label">
|
||||
<input type="radio" name="household_action" value="join" checked
|
||||
onchange="document.getElementById('join-block').hidden=false;
|
||||
document.getElementById('create-block').hidden=true;">
|
||||
Join an existing household
|
||||
</label>
|
||||
<div id="join-block" class="household-block">
|
||||
<select name="household_id" class="select-input">
|
||||
<option value="">— Select —</option>
|
||||
{% for h in households %}
|
||||
<option value="{{ h.id }}">{{ h.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if not households %}
|
||||
<p class="hint">No households yet. Create one below!</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<label class="radio-label">
|
||||
<input type="radio" name="household_action" value="create"
|
||||
onchange="document.getElementById('join-block').hidden=true;
|
||||
document.getElementById('create-block').hidden=false;"
|
||||
{% if not households %}checked{% endif %}>
|
||||
Create a new household
|
||||
</label>
|
||||
<div id="create-block" class="household-block" hidden>
|
||||
<input type="text" name="new_household_name"
|
||||
placeholder="Household name (e.g. The Smiths)"
|
||||
class="text-input">
|
||||
<p class="hint">You'll be the admin of this household.</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
<p class="form-footer">
|
||||
|
||||
Reference in New Issue
Block a user