vienalatina/apps/board/templates/members.html
Claude 28dd23e444
Publishing has never worked: one line, two wrong answers
gitea.py answered a 401 or 403 from the git server by raising
PermissionError("gitea-unauthorised"), with a comment saying the caller would
refresh and retry. That caller was tokens.py, deleted two phases ago when the
members area took over its own logins. Nothing has caught it since, so a
refused token arrived as a 500 on Contenido — Flask's own page, in English,
saying nothing — and, when approving a submission, as "no se encontró la imagen
en el disco", because PermissionError is a subclass of OSError and the approve
path caught OSError to mean a missing file. The page was displaying the
photograph two lines above the message.

Underneath both: a site-admin token cannot write to a repository. Gitea's
scopes are per category and `admin` does not contain `repository`, so the
editor has never been able to commit and nothing written in the members area
has ever reached the site. server-setup.md said the fallback to
GITEA_ADMIN_TOKEN "keeps an existing install working", which was the sentence
that hid it; it now says what that token can and cannot do.

Fixed: 401/403 raises a GiteaError naming the scope to check; approve reads the
picture before the try and catches only FileNotFoundError, so "the image is
missing" is said only when it is; and a 500 handler renders the site's own page
and logs the traceback with the request path.

Then the three wall pieces:

Every name — wall, thread, comment, private message, dashboard, directory —
renders through templates/_person.html, which links to vienalatina.com/<login>
only when that person has published a page. Both failure modes are silent, so
the rule lives in one macro instead of nine templates. A profile also has one
canonical address now: /<name>/ redirects to /<name>, which is what url_for had
been quietly preferring.

One 👍 per member per thread or comment, clicking again takes it back. The
table is shaped like attachments — two nullable parents, a CHECK that exactly
one is set — and uniqueness is two partial indexes, because UNIQUE across a
NULL column would make every comment reaction unique by accident. The `back`
field goes through auth.safe_next (renamed from _safe_next), since a redirect
somebody can type is an open redirect.

Miembros is a directory: a card per person with photo, username, role, the
first line of their bio, somewhere to write from and a link to their page.
Admin controls fold into a per-card Gestionar block. That is also the fix for
the misaligned row in the screenshot — four forms in a column two inches wide
was the cause, and the table is gone. Photos inside the members area are served
by a login-gated route even when the public page is unpublished, and the
profile form now says so.

404 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-09-30 14:39:14 +00:00

141 lines
5.8 KiB
HTML

{% extends "base.html" %}
{% from "_person.html" import person %}
{% 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>
{# People, not rows. This was a five-column table whose last column held four
forms, which is how the actions ended up wrapping on top of each other in a
column two inches wide. A card has room for a face and somewhere to write
from, and the admin controls fold away into a <details> so that the page is
a directory first and a control panel second. #}
<ul class="people">
{% for m in members %}
<li class="person-card {{ '' if m.active else 'person-card--off' }}">
<div class="person-card__head">
{% if m.photo_name %}
<img class="person-card__photo"
src="{{ url_for('profiles.member_photo', stored_name=m.photo_name) }}"
alt="" loading="lazy">
{% else %}
{# Their initial rather than a silhouette: a placeholder that is at
least theirs. #}
<span class="person-card__photo person-card__photo--none" aria-hidden="true">
{{ m.display_name[:1]|upper }}
</span>
{% endif %}
<div class="person-card__who">
<h2 class="person-card__name">
{{ person(m.display_name, m.gitea_login, m.profile_published) }}
{% if m.id == me.id %}<span class="muted small">(tú)</span>{% endif %}
</h2>
{# The username is shown to everyone: it is not a secret, it is
their address — vienalatina.com/<usuario> — and somebody
looking for a person's page needs to know how it is spelled.
The email stays inside the admin block. #}
<p class="muted small">
<span class="mono">{{ m.gitea_login }}</span> · {{ labels[m.role] }}
{% if not m.active %} · Suspendido{% endif %}
{% if m.posts %} · {{ m.posts }} en el muro{% endif %}
</p>
</div>
</div>
{% if m.bio %}<p class="person-card__bio">{{ m.bio.split('\n')[0][:160] }}</p>{% endif %}
<div class="person-card__foot">
{% if m.id != me.id and m.active %}
<a class="linkish" href="{{ url_for('messages.talk', member_id=m.id) }}">Escribir</a>
{% endif %}
{% if m.profile_published %}
<a class="linkish" href="{{ url_for('profiles_public.show', name=m.gitea_login) }}">Su página</a>
{% elif m.id == me.id %}
<a class="linkish" href="{{ url_for('profiles.edit') }}">Editar mi perfil</a>
{% endif %}
</div>
{% if is_admin and m.role != 'owner' %}
{# A <details>, not a script: the CSP has no 'unsafe-inline'. Closed by
default, so the directory reads as a directory. #}
<details class="person-card__admin">
<summary>Gestionar</summary>
<div class="person-card__actions">
<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 defeats the point.
Hidden without an address, because the handler would 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 %}
{% 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 %}
{% if m.email %}<p class="muted small">{{ m.email }}</p>{% endif %}
</div>
</details>
{% endif %}
</li>
{% endfor %}
</ul>
{% if is_admin %}
<p class="muted small">
Hay un solo responsable. El responsable da de alta administradores; los
administradores dan de alta miembros y moderadores. Nadie puede suspender ni
degradar al responsable: para dejar el cargo hay que transferirlo a un
administrador.
</p>
{% endif %}
{% endblock %}