You asked for a super-admin, and most of it already existed as the `owner` role
— labelled «Responsable», seeded from BOARD_OWNER, already the only account that
could create an admin, demote one, erase anybody or hand the role on, with a
partial unique index making "exactly one" a database rule. You chose a genuine
fifth tier anyway, and there is a reading in which that is the better answer, so
this builds it with that reading made explicit:
superadministrador — the platform: admin accounts, the look, the identity
responsable — the association: members, moderators, invitations
The split is worth more than a rename because of where this is going. Installed
for a second organisation, the superadministrator is whoever maintains the box
and the responsable is their president — so the responsable chair is safe to
hand to a customer, and an admin account is not theirs to grant.
Both chairs are unreachable, for different reasons. The superadministrator
because there is nothing above them. The responsable because the chair belongs
to the association: a platform administrator quietly removing the president of
the organisation they host is exactly the move two chairs exist to prevent.
Each steps down by handing their own chair on, and whoever gives one up becomes
an administrator — there is no role above the one they just gave away.
Migration 7 is the rebuild migration 4 already did, for the same reason (SQLite
cannot alter a CHECK), and it promotes the existing owner — Pablo — to
superadministrator, leaving the responsable chair empty for the association to
fill. Nothing is erased; you offered and it was not needed.
Two things in here would have shipped silently without a test looking for them:
`_seed_superadmin` ends `ON CONFLICT(gitea_login) DO UPDATE SET role = …`. That
line was right while owner was the top of the tree. Left as it was, it would
have matched BOARD_OWNER's login and demoted the superadministrator back to
owner **on every container restart** — a privilege reduction caused by nothing
anybody did, freeing the chair for somebody else. It takes a second start-up to
catch, so the test starts the app three times.
And seven places outside the role modules asked "is this person at least an
admin" as a literal `("owner", "admin")` tuple — the wall's delete, the editor's
page collection, the calendar's edit flag, the dashboard, the moderation
predicate. Every one of them silently excluded the superadministrator the moment
a tier appeared above owner. They are now one ordered LADDER and one
`is_at_least`, so the next tier is a word in a list rather than an audit.
Marca moves from admin-only to superadmin-only, which is the distinction you
asked for: the look and the identity are the platform's.
564 tests pass, including the predicate table per actor and target, each of the
four doors into "make an admin" closed against an admin and against the
responsable, and both single-chair indexes surviving the rebuild.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
222 lines
9.4 KiB
HTML
222 lines
9.4 KiB
HTML
{# One person's page inside the members area.
|
|
|
|
Three things in one place, in the order somebody actually wants them: who
|
|
this is, what you have said to each other, and — for an admin — what can be
|
|
done about them. It replaces two screens, `conversation.html` and the
|
|
`<details>` block that used to be on every card in the directory.
|
|
|
|
The private half is the reason this page exists and the reason it is behind
|
|
the login. Their *public* page is a separate thing they publish themselves,
|
|
linked below when they have. #}
|
|
{% extends "base.html" %}
|
|
{% from "_person.html" import person %}
|
|
{% from "_attachments.html" import attachments %}
|
|
{% block title %}{{ member.display_name }}{% endblock %}
|
|
|
|
{% set me = g.member %}
|
|
{# The template mirrors the predicates in members.py rather than restating
|
|
them: `can_assign` is the same list the handler will accept, so the picker
|
|
cannot offer a role that comes back 403. #}
|
|
{% set is_super = me.role == 'superadmin' %}
|
|
{% set is_chair = me.role in ('superadmin', 'owner') %}
|
|
{% set is_admin = me.role in ('superadmin', 'owner', 'admin') %}
|
|
{% set can_assign = assignable_roles(me.role) %}
|
|
|
|
{% block main %}
|
|
<div class="feed-head">
|
|
<h1>{{ member.display_name }}{% if is_me %} <span class="muted small">(tú)</span>{% endif %}</h1>
|
|
<a class="linkish" href="{{ url_for('members.index') }}">Todos los miembros</a>
|
|
</div>
|
|
|
|
<section class="card person-head">
|
|
{% if member.photo_name %}
|
|
<img class="person-head__photo"
|
|
src="{{ url_for('profiles.member_photo', stored_name=member.photo_name) }}"
|
|
alt="">
|
|
{% else %}
|
|
<span class="person-head__photo person-head__photo--none" aria-hidden="true">
|
|
{{ member.display_name[:1]|upper }}
|
|
</span>
|
|
{% endif %}
|
|
|
|
<div class="person-head__who">
|
|
<p class="muted small">
|
|
<span class="mono">{{ member.gitea_login }}</span> · {{ labels[member.role] }}
|
|
{% if not member.active %} · Suspendido{% endif %}
|
|
</p>
|
|
|
|
{% if member.bio %}<div class="prose">{{ bio_html }}</div>{% endif %}
|
|
|
|
{% if links %}
|
|
<ul class="person-head__links">
|
|
{% for link in links %}
|
|
{# nofollow noopener as on the public page: these are addresses a
|
|
member typed, and this page is no safer a place to vouch for them. #}
|
|
<li><a href="{{ link.url }}" rel="nofollow noopener">{{ link.label or link.url }}</a></li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% endif %}
|
|
|
|
<p class="person-head__foot">
|
|
{% if member.profile_published %}
|
|
<a class="linkish" href="{{ url_for('profiles_public.show', name=member.gitea_login) }}">Su página pública</a>
|
|
{% elif is_me %}
|
|
<a class="linkish" href="{{ url_for('profiles.edit') }}">Editar mi perfil</a>
|
|
{% else %}
|
|
<span class="muted small">No ha publicado una página pública.</span>
|
|
{% endif %}
|
|
</p>
|
|
</div>
|
|
</section>
|
|
|
|
{% if is_me %}
|
|
{# No conversation with yourself, and nothing to mark read. Your own private
|
|
messages are each on the page of the person you had them with, which is the
|
|
whole arrangement. #}
|
|
<p class="muted">
|
|
Esta es tu ficha, tal como la ven los demás. Para escribir a alguien, abre su
|
|
ficha desde <a href="{{ url_for('members.index') }}">Miembros</a>.
|
|
</p>
|
|
{% else %}
|
|
|
|
<h2 class="section-title">Conversación privada</h2>
|
|
<p class="muted small">
|
|
Sólo vosotros dos podéis leer esto.
|
|
</p>
|
|
|
|
{% for m in messages %}
|
|
<article class="card card--comment">
|
|
<div class="card__meta">
|
|
<span>{{ person(m.author, m.author_login) }}</span> · <time>{{ m.created_at }}</time>
|
|
</div>
|
|
<div class="prose">{{ to_html(m.body_md) }}</div>
|
|
{{ attachments(images.get(m.id, [])) }}
|
|
</article>
|
|
{% else %}
|
|
<p class="muted">Todavía no os habéis escrito. Empieza abajo.</p>
|
|
{% endfor %}
|
|
|
|
<span id="final"></span>
|
|
|
|
{% if blocked %}
|
|
<p class="muted">
|
|
Hay un bloqueo entre vosotros, así que ninguno de los dos puede escribir.
|
|
</p>
|
|
<form method="post" action="{{ url_for('messages.unblock', member_id=member.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish" type="submit">Quitar mi bloqueo</button>
|
|
</form>
|
|
<p class="muted small">
|
|
Si el bloqueo lo puso la otra persona, esto no lo quita.
|
|
</p>
|
|
{% elif not member.active %}
|
|
{# The handler refuses a message to a suspended member, so the box is not drawn
|
|
for one. Said plainly rather than left as a missing form. #}
|
|
<p class="muted">
|
|
{{ member.display_name }} tiene el acceso suspendido y no puede recibir mensajes.
|
|
</p>
|
|
{% else %}
|
|
<form class="card" method="post" enctype="multipart/form-data"
|
|
action="{{ url_for('messages.talk', member_id=member.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<label for="body">Mensaje</label>
|
|
<textarea id="body" data-markdown name="body" rows="4"
|
|
placeholder="Se puede usar Markdown: **negrita**, listas, enlaces."></textarea>
|
|
|
|
<label for="pictures">Imágenes <span class="muted small">(opcional)</span></label>
|
|
<input id="pictures" name="pictures" type="file" multiple accept="image/*">
|
|
|
|
<button class="btn" type="submit">Enviar</button>
|
|
</form>
|
|
|
|
<details class="person-block">
|
|
<summary>Bloquear a {{ member.display_name }}</summary>
|
|
<p class="muted small">
|
|
Un bloqueo va en los dos sentidos: ninguno de los dos podrá escribir al
|
|
otro. Lo puedes quitar cuando quieras, pero sólo el tuyo.
|
|
</p>
|
|
<form method="post" action="{{ url_for('messages.block', member_id=member.id) }}"
|
|
data-confirm="Ninguno de los dos podrá escribir al otro. ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish linkish--danger" type="submit">Bloquear</button>
|
|
</form>
|
|
</details>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% if is_admin and member.role not in ('superadmin', 'owner') and not is_me %}
|
|
{# Moved here from the directory cards. A <details>, not a script: the CSP has
|
|
no 'unsafe-inline'. Every button is still checked in its handler — this block
|
|
being hidden from a moderator is a courtesy, not the rule. #}
|
|
<details class="person-card__admin">
|
|
<summary>Gestionar</summary>
|
|
<div class="person-card__actions">
|
|
<form method="post" action="{{ url_for('members.set_active', member_id=member.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<input type="hidden" name="active" value="{{ 0 if member.active else 1 }}">
|
|
<button class="linkish" type="submit">{{ 'Suspender' if member.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 member.email and member.active %}
|
|
<form method="post" action="{{ url_for('members.invite', member_id=member.id) }}"
|
|
data-confirm="Se enviará un enlace nuevo a {{ member.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 member.role in can_assign or member.role not in ('admin',) %}
|
|
<form class="inline-form" method="post"
|
|
action="{{ url_for('members.set_role', member_id=member.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<label class="sr-only" for="role">Rol de {{ member.display_name }}</label>
|
|
<select id="role" name="role">
|
|
{% for role in can_assign %}
|
|
<option value="{{ role }}" {{ 'selected' if member.role == role }}>{{ labels[role] }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button class="linkish" type="submit">Cambiar rol</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{% if is_chair and member.active %}
|
|
{# Naming the responsable: the association's chair. The superadministrator
|
|
can fill it when it is empty — a fresh install has nobody in it — and
|
|
the responsable can hand it on. #}
|
|
<form method="post" action="{{ url_for('members.transfer', member_id=member.id) }}"
|
|
data-confirm="{{ member.display_name }} pasará a ser el responsable de la asociación. ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish" type="submit">Nombrar responsable</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{% if is_super and member.role == 'admin' and member.active %}
|
|
{# Handing the platform on. Its own button, and its own sentence, because
|
|
it is irreversible from this side: the moment it commits you are an
|
|
administrator and cannot take it back. #}
|
|
<form method="post" action="{{ url_for('members.transfer_platform', member_id=member.id) }}"
|
|
data-confirm="{{ member.display_name }} pasará a ser el superadministrador y tú pasarás a ser administrador. No podrás deshacerlo tú mismo. ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish linkish--danger" type="submit">Entregar la plataforma</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{% if is_chair %}
|
|
<form method="post" action="{{ url_for('members.erase', member_id=member.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 member.email %}<p class="muted small">{{ member.email }}</p>{% endif %}
|
|
{% if member.creator %}<p class="muted small">Dado de alta por {{ member.creator }}.</p>{% endif %}
|
|
</div>
|
|
</details>
|
|
{% endif %}
|
|
{% endblock %}
|