Features tab: create/edit flags, flip global switches, and toggle a flag per club from the club detail page. Where `everyone` is set the per-club toggle is replaced by a badge, because a toggle there would have no effect and so would lie about what is on. Admins tab: grant, promote, demote and revoke platform access. Gated on is_superuser, not is_staff -- the panel itself is staff-accessible, so letting staff grant is_superuser would collapse the two levels into one and stop is_superuser being a boundary we can later hang anything on. Two guardrails, enforced in the service so they hold regardless of caller: you cannot strip your own access (you would lose the panel mid-click), and the last superuser can never be demoted (the platform would be locked out of itself). Granted users get an unusable password and must enrol 2FA before they can sign in. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
88 lines
4.3 KiB
HTML
88 lines
4.3 KiB
HTML
{% extends "controlpanel/base.html" %}
|
|
{% load lucide %}
|
|
|
|
{% block heading %}Features{% endblock heading %}
|
|
|
|
{% block actions %}
|
|
<a class="btn btn-primary gap-2" href="{% url 'controlpanel:flag_create' %}">{% lucide "plus" size=16 %} New feature</a>
|
|
{% endblock actions %}
|
|
|
|
{% block panel %}
|
|
<div class="card mb-6 bg-base-100 shadow">
|
|
<div class="card-body">
|
|
<h2 class="card-title text-base">{% lucide "flag" size=18 %} Flags</h2>
|
|
<p class="text-sm opacity-70">
|
|
Flags are turned on per club. Setting <em>Everyone</em> to Yes or No overrides club targeting entirely.
|
|
</p>
|
|
<div class="overflow-x-auto">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Everyone</th>
|
|
<th>Clubs</th>
|
|
<th>Note</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for flag in flags %}
|
|
<tr>
|
|
<td class="font-mono font-medium">{{ flag.name }}</td>
|
|
<td>
|
|
{% if flag.everyone is True %}
|
|
<span class="badge badge-success">On for all</span>
|
|
{% elif flag.everyone is False %}
|
|
<span class="badge badge-error">Off everywhere</span>
|
|
{% else %}
|
|
<span class="badge badge-ghost">Per club</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ flag.clubs.count }}</td>
|
|
<td class="max-w-xs truncate opacity-70">{{ flag.note|default:"—" }}</td>
|
|
<td class="text-right">
|
|
<a class="btn btn-ghost btn-xs gap-1" href="{% url 'controlpanel:flag_update' flag.pk %}">{% lucide "pencil" size=14 %} Edit</a>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="5" class="text-center opacity-60">No features yet.</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card bg-base-100 shadow">
|
|
<div class="card-body">
|
|
<h2 class="card-title text-base">{% lucide "power" size=18 %} Switches</h2>
|
|
<p class="text-sm opacity-70">Global on/off for the whole platform — kill-switches, maintenance, infra rollouts.</p>
|
|
<div class="overflow-x-auto">
|
|
<table class="table">
|
|
<tbody>
|
|
{% for switch in switches %}
|
|
<tr>
|
|
<td class="font-mono font-medium">{{ switch.name }}</td>
|
|
<td class="opacity-70">{{ switch.note|default:"—" }}</td>
|
|
<td class="text-right">
|
|
<form method="post" action="{% url 'controlpanel:switch_toggle' switch.pk %}">
|
|
{% csrf_token %}
|
|
<button class="btn btn-sm gap-1 {% if switch.active %}btn-success{% else %}btn-ghost{% endif %}" type="submit">
|
|
{% if switch.active %}{% lucide "toggle-right" size=16 %} On{% else %}{% lucide "toggle-left" size=16 %} Off{% endif %}
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td class="text-center opacity-60">No switches yet — add one in the Django admin.</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock panel %}
|