Add account deletion, admin user removal, household deletion, grayed-out other-user chips (47 tests)

This commit is contained in:
agentbox
2026-07-31 22:12:13 +00:00
parent 53a1ceab75
commit 188aaf66a0
5 changed files with 272 additions and 8 deletions
+45 -7
View File
@@ -27,40 +27,54 @@
{% for period in dashboard.periods %}
<th class="meal-col">{{ period.meal_type|capitalize }}</th>
{% endfor %}
{% if is_admin %}
<th class="action-col"></th>
{% endif %}
</tr>
</thead>
<tbody>
{% for user in dashboard.users %}
{% set is_me = user.id == current_user_id %}
<tr>
<td class="user-cell">{{ user.username }}</td>
<td class="user-cell">
{{ user.username }}
{% if user.is_admin %}<span class="admin-tag">admin</span>{% endif %}
{% if is_me %}<span class="you-tag">you</span>{% endif %}
</td>
{% for period in dashboard.periods %}
{% set resp = user.responses[period.meal_type] %}
<td class="response-cell status-{{ resp.status }}{% if resp.changed_at %} changed-mind{% endif %}">
{% if viewing_date >= today or session.is_admin %}
{% if is_me and viewing_date >= today %}
<form method="POST" action="{{ url_for('meals.respond') }}" class="respond-form">
<input type="hidden" name="date" value="{{ viewing_date.isoformat() }}">
<input type="hidden" name="meal_type" value="{{ period.meal_type }}">
<div class="btn-row">
<button name="status" value="yes"
class="chip chip-yes {% if resp.status == 'yes' %}active{% endif %}"
{% if viewing_date < today and not session.is_admin %}disabled{% endif %}
>Home</button>
<button name="status" value="no"
class="chip chip-no {% if resp.status == 'no' %}active{% endif %}"
{% if viewing_date < today and not session.is_admin %}disabled{% endif %}
>Out</button>
</div>
</form>
{% if resp.changed_at %}
<div class="changed-badge" title="Changed mind at {{ resp.changed_at }}">↻ {{ resp.changed_at[11:16] }}</div>
{% endif %}
{% elif resp.status == 'not_answered' %}
<span class="muted"></span>
{% else %}
<span class="badge badge-{{ resp.status }}">{{ 'Home' if resp.status == 'yes' else 'Out' }}</span>
<span class="badge badge-{{ resp.status }}">{{ 'Home' if resp.status == 'yes' else ('Out' if resp.status == 'no' else '—') }}</span>
{% endif %}
</td>
{% endfor %}
{% if is_admin and not is_me and not user.is_admin %}
<td class="action-cell">
<form method="POST" action="{{ url_for('meals.admin_remove_user', user_id=user.id) }}"
onsubmit="return confirm('Remove {{ user.username }} from this household?');">
<button class="btn btn-sm btn-danger">Remove</button>
</form>
</td>
{% elif is_admin %}
<td class="action-cell"></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
@@ -68,4 +82,28 @@
</div>
{% endif %}
<div class="manage-section">
<details class="manage-details">
<summary>⚙ Account Settings</summary>
<div class="manage-forms">
<form method="POST" action="{{ url_for('meals.delete_account') }}"
onsubmit="return confirm('Delete YOUR account? This cannot be undone.');" class="manage-form">
<h4>Delete My Account</h4>
<input type="password" name="password" placeholder="Enter your password to confirm" required>
<button class="btn btn-danger">Delete My Account</button>
</form>
{% if is_admin %}
<form method="POST" action="{{ url_for('meals.admin_delete_household') }}"
onsubmit="return confirm('Delete the ENTIRE household and ALL members? This cannot be undone.');" class="manage-form">
<h4>Delete Household</h4>
<p class="hint">This will remove all users and all data in this household.</p>
<input type="password" name="password" placeholder="Enter your password to confirm" required>
<button class="btn btn-danger">Delete Household</button>
</form>
{% endif %}
</div>
</details>
</div>
{% endblock %}