The members area had grown one navigation entry per phase, and three of the five were inside an admin-only block in base.html — so an ordinary member signed in to a wall and a member list, with their own profile, their own private messages and the content editor all invisible. Everything worked and nothing was reachable. That is the bug this starts from. The navigation is now Inicio · Muro · Privados · Publicaciones, plus Gestión for admins, and the account items (Mi perfil, Descargar mis datos, Salir) moved to a menu under the member's own name — a <details> element, because the CSP has no 'unsafe-inline' and a menu needing onclick="" silently never opens. Inicio is a new dashboard; the wall moved from /comunidad/ to /comunidad/muro and kept its thread URLs. test_navigation.py asserts the navigation per role from the rendered page, so this cannot come back quietly. Public posts are now curated. A member proposes one and it waits in a new `submissions` table; a moderator or admin approves it — which commits it through content.publish, the same function the editor uses, with the author named per commit so git history says who wrote it, not who approved it — or returns it with a reason the author reads. Moderators and admins do not queue. Nothing a member writes reaches the repository before approval, because a commit to it *is* publication: the webhook starts the pipeline. A proposal's picture stays private in /data/uploads until then, and the private copy goes when the public one is committed. There is deliberately no way to promote a wall thread into a proposal. The moderator role needed the role CHECK widened, and SQLite has no DROP CONSTRAINT, so migration 4 rebuilds `members` — eight tables reference it, the one-owner index has to be recreated by hand, and PRAGMA foreign_key_check runs before the commit. One trap worth recording: the allowed roles can only be read back out of sqlite_master's verbatim CREATE TABLE text, comments included, so schema.sql's own comment explaining the rebuild made the step decide it had already run. The start-up test caught it; comments are stripped now. A moderator curates content and has no power over people: no creating, suspending, promoting or erasing anybody. set_role moved from owner-only to admin-level so moderators can be appointed routinely, and checks may_create on the new role as well, so admins still cannot mint admins. content.py splits per collection — posts need a moderator, the site's static pages need an admin. Also: erasure deletes a member's submissions and their pictures and clears reviewed_by, which the existing foreign-key guard forced; deploy-board.sh takes a backup before restarting, since two migrations now rebuild a table in place and one of them holds your own account; README and docs/server-setup.md updated for the roles, the sections and migration 4. 370 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
99 lines
4.2 KiB
HTML
99 lines
4.2 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Miembros{% endblock %}
|
|
|
|
{% set me = g.member %}
|
|
{% set is_owner = me.role == 'owner' %}
|
|
{% set is_admin = me.role in ('owner', 'admin') %}
|
|
|
|
{% block main %}
|
|
<div class="feed-head">
|
|
<h1>Miembros</h1>
|
|
{% if is_admin %}
|
|
<a class="btn" href="{{ url_for('members.new') }}">Dar de alta</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<table class="table">
|
|
<thead>
|
|
<tr><th>Nombre</th><th>Usuario</th><th>Rol</th><th>Estado</th>{% if is_admin %}<th></th>{% endif %}</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for m in members %}
|
|
<tr class="{{ '' if m.active else 'row--off' }}">
|
|
<td>{{ m.display_name }}{% if m.id == me.id %} <span class="muted small">(tú)</span>{% endif %}</td>
|
|
<td class="mono">{{ m.gitea_login }}</td>
|
|
<td>{{ labels[m.role] }}</td>
|
|
<td>{{ 'Activo' if m.active else 'Suspendido' }}</td>
|
|
{% if is_admin %}
|
|
<td class="actions actions--row">
|
|
{# The owner is untouchable, so the row shows nothing rather than
|
|
buttons that would only produce a 403. #}
|
|
{% if m.role != 'owner' %}
|
|
<form method="post" action="{{ url_for('members.set_active', member_id=m.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<input type="hidden" name="active" value="{{ 0 if m.active else 1 }}">
|
|
<button class="linkish" type="submit">{{ 'Suspender' if m.active else 'Reactivar' }}</button>
|
|
</form>
|
|
|
|
{# Any admin can re-send, not just the owner: the usual reason
|
|
somebody needs this is that the admin who added them made
|
|
the account by hand, and waiting for the owner to be
|
|
around defeats the point. Hidden without an address,
|
|
because the handler would only refuse. #}
|
|
{% if m.email and m.active %}
|
|
<form method="post" action="{{ url_for('members.invite', member_id=m.id) }}"
|
|
data-confirm="Se enviará un enlace nuevo a {{ m.email }} y el anterior dejará de servir. ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish" type="submit">Enviar invitación</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{# A toggle worked while there were two roles. With three it has to
|
|
be a choice, and the options are the ones this person may
|
|
actually grant — the handler checks the same thing. #}
|
|
{% if is_owner or m.role != 'admin' %}
|
|
<form class="inline-form" method="post"
|
|
action="{{ url_for('members.set_role', member_id=m.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<label class="sr-only" for="role-{{ m.id }}">Rol de {{ m.display_name }}</label>
|
|
<select id="role-{{ m.id }}" name="role">
|
|
<option value="user" {{ 'selected' if m.role == 'user' }}>Miembro</option>
|
|
<option value="moderator" {{ 'selected' if m.role == 'moderator' }}>Moderador</option>
|
|
{% if is_owner %}
|
|
<option value="admin" {{ 'selected' if m.role == 'admin' }}>Administrador</option>
|
|
{% endif %}
|
|
</select>
|
|
<button class="linkish" type="submit">Cambiar rol</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{% if is_owner %}
|
|
{% if m.role == 'admin' and m.active %}
|
|
<form method="post" action="{{ url_for('members.transfer', member_id=m.id) }}"
|
|
data-confirm="Vas a dejar de ser el responsable y {{ m.display_name }} pasará a serlo. ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish" type="submit">Transferir titularidad</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
<form method="post" action="{{ url_for('members.erase', member_id=m.id) }}"
|
|
data-confirm="Se borrarán sus datos personales. Sus mensajes quedarán como «Miembro eliminado». ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish linkish--danger" type="submit">Eliminar</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
</td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<p class="muted small">
|
|
Hay un solo responsable. El responsable da de alta administradores; los
|
|
administradores dan de alta usuarios. Nadie puede suspender ni degradar al
|
|
responsable: para dejar el cargo hay que transferirlo a un administrador.
|
|
</p>
|
|
{% endblock %}
|