Private messages live on the person, not in a tab

*Privados* was a section holding a list of conversations, and *Miembros* was a
page reached from the footer. That is backwards: the list of conversations is a
by-product and the people are the thing. So the navigation swaps them —
**Inicio · Muro · Miembros · Publicaciones · Calendario · Gestión** — the grid
becomes faces and names, and writing to somebody and reading what the two of
you have written each other both happen on their page.

`/comunidad/miembro/<usuario>` is new, keyed on the login so the address
matches the public one. It carries their photo, bio and links, a link out to
their public page when they have published one, the whole conversation with
them, the write box, block/unblock, and — for an admin — the controls that used
to be folded into every card in the directory. `conversation.html` and
`inbox.html` are gone; `member.html` replaces both.

The split between the two modules did not move. `messages.py` still owns every
rule about private messages — who may read a conversation, what counts as
having read it, when the conversation comes into being, who may write to whom —
and hands the page its contents through the new `history()`. What is left of
its routes are the ones that change something: a message sent, a block set or
lifted. `members.show` renders.

Not losing the unread badge is the part with a real design question in it, and
it takes four things: the badge moves to *Miembros*, each card carries its own
count, the cards with something unread sort to the top of the grid, and Inicio
keeps the panel it already had. Without the sort, the person waiting for an
answer is wherever the alphabet put them, which is the one thing the inbox did
that a grid of faces does not.

Names now link inside. `_person.html` used to link to somebody's *public* page
and only when they had published one, so most names on the wall were plain
text and there was no way to get from a post to writing to its author. Every
caller is behind the login, so it points at the members-area page instead —
with the tombstone as the one name with nothing behind it.

Old addresses redirect: `/comunidad/privados` to the directory,
`/comunidad/privados/con/<id>` to that person's page. The POST that sends a
message keeps its address, which is what the form on the new page uses.

512 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
This commit is contained in:
admin 2026-10-03 20:12:16 +00:00
parent 1e1113ed53
commit 91aa0c9a9e
No known key found for this signature in database
23 changed files with 871 additions and 475 deletions

View File

@ -13,7 +13,7 @@ from datetime import datetime, timezone
from flask import Flask, render_template, request
from werkzeug.middleware.proxy_fix import ProxyFix
from .db import close_db, init_db
from .db import TOMBSTONE_LOGIN, close_db, init_db
from .security import check_csrf, csrf_token
URL_PREFIX = "/comunidad"
@ -114,6 +114,9 @@ def create_app(overrides: dict | None = None) -> Flask:
app.teardown_appcontext(close_db)
app.jinja_env.globals["csrf_token"] = csrf_token
app.jinja_env.globals["url_prefix"] = URL_PREFIX
# For _person.html: the one login with no page behind it. A literal in the
# template would be the same string written twice, in two languages.
app.jinja_env.globals["tombstone_login"] = TOMBSTONE_LOGIN
@app.context_processor
def _year():

View File

@ -122,7 +122,7 @@ def session_state():
sections = [
{"label": "Inicio", "url": url_for("home.index")},
{"label": "Muro", "url": url_for("board.threads")},
{"label": "Privados", "url": url_for("messages.inbox")},
{"label": "Miembros", "url": url_for("members.index")},
{"label": "Publicaciones", "url": url_for("submissions.index")},
{"label": "Calendario", "url": url_for("events.month")},
]

View File

@ -27,8 +27,9 @@ import sqlite3
from flask import (Blueprint, Response, abort, current_app, flash, g, redirect,
render_template, request, url_for)
from . import auth, invites, mail, profiles, uploads
from . import auth, invites, mail, messages, profiles, uploads
from .db import TOMBSTONE_LOGIN, get_db
from .render import to_html
from .security import admin_required, login_required, owner_required
bp = Blueprint("members", __name__)
@ -224,23 +225,91 @@ def _load(member_id: int):
return row
def _page(target) -> str:
"""Back to the person whose page the button was on.
The admin controls used to sit on the cards, so every one of them sent the
admin back to the directory. They are on the person's page now, and landing
on the page you just changed — with the flash above it — is the difference
between seeing that it worked and going to look for it.
"""
return url_for("members.show", login=target["gitea_login"])
@bp.route("/miembros")
@login_required
def index():
"""The directory, and the way into every private conversation.
Faces and names, and nothing else on a card: this is a section of the site
now, not an admin screen, and everything about one person — their page,
their messages, and the admin controls — is on their own page one click
away.
**Sorted by who wrote to you, first.** That is what makes a directory work
as the entrance to private messages: without it, the person waiting for an
answer is wherever the alphabet put them. The role order comes second, so a
page with nothing unread looks exactly as it did before.
"""
rows = get_db().execute(
"""SELECT m.*, c.display_name AS creator,
f"""SELECT m.*, c.display_name AS creator,
(SELECT COUNT(*) FROM threads t
WHERE t.author_id = m.id AND t.deleted_at IS NULL) AS posts
WHERE t.author_id = m.id AND t.deleted_at IS NULL) AS posts,
({messages.unread_sql()}) AS unread
FROM members m
LEFT JOIN members c ON c.id = m.created_by
WHERE m.role != 'tombstone'
ORDER BY CASE m.role WHEN 'owner' THEN 0 WHEN 'admin' THEN 1
ORDER BY CASE WHEN unread > 0 THEN 0 ELSE 1 END,
CASE m.role WHEN 'owner' THEN 0 WHEN 'admin' THEN 1
WHEN 'moderator' THEN 2 ELSE 3 END,
m.display_name COLLATE NOCASE"""
m.display_name COLLATE NOCASE""",
{"me": g.member["id"]},
).fetchall()
return render_template("members.html", members=rows, labels=ROLE_LABELS)
@bp.route("/miembro/<login>")
@login_required
def show(login: str):
"""One person: who they are, and everything between you and them.
Keyed on the login rather than the row id so the address matches the public
one — `/comunidad/miembro/maria` beside `vienalatina.com/maria` — and so a
link written by hand is guessable.
Suspended members are shown rather than hidden: they are in the directory,
an admin needs to reach their controls to reactivate them, and a page that
404s for somebody visible one click earlier is its own small mystery. What
they do not get is a write box — see the template.
"""
member = get_db().execute(
"""SELECT m.*, c.display_name AS creator FROM members m
LEFT JOIN members c ON c.id = m.created_by
WHERE m.gitea_login = ? COLLATE NOCASE AND m.role != 'tombstone'""",
(login,),
).fetchone()
if member is None:
abort(404)
mine = member["id"] == g.member["id"]
# Nothing to read, nothing to mark read, and no conversation with yourself.
talk = ({"messages": [], "images": {}, "blocked": False} if mine
else messages.history(member["id"]))
try:
links = json.loads(member["links"] or "[]")
except ValueError:
# A profile whose links column is unreadable still has a page. Half a
# page with a traceback in the log is better than none with one on
# screen.
links = []
return render_template(
"member.html", member=member, labels=ROLE_LABELS, is_me=mine,
messages=talk["messages"], images=talk["images"], blocked=talk["blocked"],
links=links, bio_html=to_html(member["bio"] or ""), to_html=to_html,
)
@bp.route("/miembros/nuevo", methods=["GET", "POST"])
@admin_required
def new():
@ -338,7 +407,7 @@ def invite(member_id: int):
target = _load(member_id)
if not target["email"]:
flash(f"{target['display_name']} no tiene correo. Añádelo primero.", "error")
return redirect(url_for("members.index"))
return redirect(_page(target))
if not target["active"] or target["role"] == "tombstone":
abort(403)
@ -351,10 +420,10 @@ def invite(member_id: int):
# did not work.
current_app.logger.warning("Invite mail to %s failed: %s", target["email"], exc)
flash(f"No se pudo enviar el correo. Pásale este enlace: {link}", "error")
return redirect(url_for("members.index"))
return redirect(_page(target))
flash(f"Invitación enviada a {target['email']}.", "ok")
return redirect(url_for("members.index"))
return redirect(_page(target))
@bp.route("/miembros/<int:member_id>/estado", methods=["POST"])
@ -366,7 +435,7 @@ def set_active(member_id: int):
active = 1 if request.form.get("active") == "1" else 0
get_db().execute("UPDATE members SET active = ? WHERE id = ?", (active, member_id))
flash(f"{target['display_name']}: acceso {'restaurado' if active else 'suspendido'}.", "ok")
return redirect(url_for("members.index"))
return redirect(_page(target))
@bp.route("/miembros/<int:member_id>/rol", methods=["POST"])
@ -390,7 +459,7 @@ def set_role(member_id: int):
abort(403)
get_db().execute("UPDATE members SET role = ? WHERE id = ?", (role, member_id))
flash(f"{target['display_name']} ahora es {ROLE_LABELS[role].lower()}.", "ok")
return redirect(url_for("members.index"))
return redirect(_page(target))
@bp.route("/miembros/<int:member_id>/transferir", methods=["POST"])
@ -399,10 +468,10 @@ def transfer(member_id: int):
target = _load(member_id)
if target["role"] != "admin" or not target["active"]:
flash("Solo puedes transferir la titularidad a un administrador activo.", "error")
return redirect(url_for("members.index"))
return redirect(_page(target))
transfer_ownership(get_db(), g.member["id"], target["id"])
flash(f"{target['display_name']} es ahora el responsable. Tú eres administrador.", "ok")
return redirect(url_for("members.index"))
return redirect(_page(target))
@bp.route("/miembros/<int:member_id>/eliminar", methods=["POST"])

View File

@ -1,9 +1,19 @@
"""Private messages between two members.
An inbox, not a chat. Each conversation has exactly two people, each keeps
their own unread mark, and either can block the other — after which neither can
write. That symmetry is deliberate: a block that silences only one side is a
one-way megaphone, which is worse than having no block at all.
Not a chat, and — since the sections were rearranged — not an inbox either.
Each conversation has exactly two people, each keeps their own unread mark, and
either can block the other, after which neither can write. That symmetry is
deliberate: a block that silences only one side is a one-way megaphone, which is
worse than having no block at all.
**Where the messages are shown moved; where the rules live did not.** The
conversation is read on the other person's page (`members.show`), because
writing to somebody is something you do to a person and not in a separate
mailbox. This module still owns every rule about it — who may read a
conversation, what counts as having read it, when the conversation comes into
being, and who may write to whom — and hands the page its contents through
`history()`. The routes that remain are the ones that *change* something: a
message sent, a block set or lifted.
Every rule here is enforced in the handler, not only in the template. A hidden
button is a courtesy to somebody using the site normally; it is not a rule, and
@ -12,12 +22,10 @@ the difference matters most for exactly the person a block exists to stop.
from __future__ import annotations
from flask import (Blueprint, abort, flash, g, redirect, render_template,
request, url_for)
from flask import Blueprint, abort, flash, g, redirect, request, url_for
from . import uploads
from .db import TOMBSTONE_LOGIN, get_db
from .render import to_html
from .db import get_db
from .security import login_required
bp = Blueprint("messages", __name__)
@ -87,121 +95,51 @@ def unread_count() -> int:
).fetchone()["n"]
# --- routes ---------------------------------------------------------------
def unread_sql(me: str = ":me", other: str = "m.id") -> str:
"""How many unread messages the signed-in member has from `other`.
@bp.route("/privados")
@login_required
def inbox():
rows = get_db().execute(
"""SELECT c.id,
other.display_name AS other_name,
other.id AS other_id,
other.gitea_login AS other_login,
other.profile_published AS other_published,
(SELECT body_md FROM messages
WHERE conversation_id = c.id AND deleted_at IS NULL
ORDER BY created_at DESC LIMIT 1) AS last_body,
(SELECT created_at FROM messages
WHERE conversation_id = c.id AND deleted_at IS NULL
ORDER BY created_at DESC LIMIT 1) AS last_at,
(SELECT COUNT(*) FROM messages m
WHERE m.conversation_id = c.id AND m.author_id != mine.member_id
AND m.deleted_at IS NULL
AND (mine.last_read_at IS NULL OR m.created_at > mine.last_read_at)
) AS unread
FROM conversations c
A string rather than a function because its one caller is the directory
query in `members.index`, which needs the number per row and sorts on it —
one query that answers for everybody, rather than one query per face on the
page. The two parameters are SQL fragments chosen by this module, never by a
request.
`author_id = other` is what makes it unread *from them*: a member's own
messages are not unread, and without that clause looking at your own card
would count everything you have ever written.
"""
return f"""
SELECT COUNT(*) FROM messages msg
JOIN conversation_members mine
ON mine.conversation_id = c.id AND mine.member_id = :me
ON mine.conversation_id = msg.conversation_id AND mine.member_id = {me}
JOIN conversation_members theirs
ON theirs.conversation_id = c.id AND theirs.member_id != :me
JOIN members other ON other.id = theirs.member_id
ORDER BY last_at DESC NULLS LAST""",
{"me": g.member["id"]},
).fetchall()
# Anyone you could start writing to: every active member but yourself, the
# tombstone, and anyone either of you has blocked.
people = get_db().execute(
"""SELECT m.id, m.display_name FROM members m
WHERE m.id != :me AND m.active = 1
AND m.role != 'tombstone'
AND m.gitea_login != :ghost
AND NOT EXISTS (SELECT 1 FROM blocks
WHERE (blocker_id = :me AND blocked_id = m.id)
OR (blocker_id = m.id AND blocked_id = :me))
ORDER BY m.display_name COLLATE NOCASE""",
{"me": g.member["id"], "ghost": TOMBSTONE_LOGIN},
).fetchall()
return render_template("inbox.html", conversations=rows, people=people,
excerpt=lambda text: (text or "")[:120])
@bp.route("/privados/con")
@login_required
def pick():
"""The select posts here as a plain GET and is sent on to the conversation.
A form cannot put its own value into a path, and rewriting the action with
JavaScript is not available: the Content-Security-Policy has no
'unsafe-inline', so an inline handler is ignored without a word. One tiny
redirect avoids the whole question.
ON theirs.conversation_id = msg.conversation_id AND theirs.member_id = {other}
WHERE msg.author_id = {other}
AND {other} != {me}
AND msg.deleted_at IS NULL
AND (mine.last_read_at IS NULL OR msg.created_at > mine.last_read_at)
"""
return redirect(url_for("messages.talk",
member_id=request.args.get("member_id", type=int) or 0))
@bp.route("/privados/con/<int:member_id>", methods=["GET", "POST"])
@login_required
def talk(member_id: int):
"""One page for a conversation, whether or not it exists yet.
def history(other_id: int) -> dict:
"""The conversation with `other_id`, and the fact of having read it.
There used to be an "Abrir conversación" step that created an empty
conversation and sent you to it. It bought nothing — you still had to type
a message afterwards — and it littered the inbox with rows saying "Sin
mensajes todavía" for people nobody had actually written to. The
conversation is now created by the first message, not by looking at
somebody's name.
Called by the member page, which renders it. Reading is a side effect on
purpose: opening somebody's page *is* opening the conversation, there is no
second step any more, and so there is no moment at which the messages are on
screen and still counted as unread.
Creates nothing. A conversation comes into being with the first message
(`talk` below), so looking at a page is not enough to put a row in the
database — which is what kept the old inbox free of entries saying "no
messages yet" for people nobody had written to.
"""
if member_id == g.member["id"]:
abort(400)
other = get_db().execute(
"""SELECT * FROM members
WHERE id = ? AND active = 1 AND role != 'tombstone'""",
(member_id,),
).fetchone()
if other is None:
abort(404)
blocked = blocked_between(g.member["id"], member_id)
if blocked and request.method == "POST":
abort(403)
db = get_db()
conversation_id = existing_conversation(member_id)
if request.method == "POST":
body = request.form.get("body", "").strip()[:BODY_MAX]
try:
staged = uploads.stage(request.files.getlist("pictures"))
except uploads.RejectedUpload as exc:
flash(str(exc), "error")
return redirect(url_for("messages.talk", member_id=member_id))
if not body and not staged:
flash("Escribe algo o adjunta una imagen.", "error")
return redirect(url_for("messages.talk", member_id=member_id))
# Only now does the conversation come into being.
blocked = blocked_between(g.member["id"], other_id)
conversation_id = existing_conversation(other_id)
if conversation_id is None:
conversation_id = conversation_with(member_id)
cursor = db.execute(
"INSERT INTO messages (conversation_id, author_id, body_md) VALUES (?, ?, ?)",
(conversation_id, g.member["id"], body),
)
uploads.save(staged, g.member["id"], message_id=cursor.lastrowid)
return redirect(url_for("messages.talk", member_id=member_id) + "#final")
return {"messages": [], "images": {}, "blocked": blocked}
rows = []
if conversation_id is not None:
rows = db.execute(
"""SELECT m.*, a.display_name AS author,
a.gitea_login AS author_login,
@ -216,12 +154,89 @@ def talk(member_id: int):
WHERE conversation_id = ? AND member_id = ?""",
(conversation_id, g.member["id"]),
)
return {
"messages": rows,
"images": uploads.for_messages([row["id"] for row in rows]),
"blocked": blocked,
}
return render_template(
"conversation.html", other=other, messages=rows, to_html=to_html,
images=uploads.for_messages([row["id"] for row in rows]),
blocked=blocked,
def _back_to(member_row, anchor: str = "") -> str:
return url_for("members.show", login=member_row["gitea_login"]) + anchor
# --- routes ---------------------------------------------------------------
@bp.route("/privados")
@login_required
def inbox():
"""Kept as a redirect, not deleted.
This was the *Privados* section until the people became the section. The
route stays because members have the address in their history and admins
have it written down, and a bookmark that lands on the directory is a
bookmark that still works.
"""
return redirect(url_for("members.index"))
@bp.route("/privados/con/<int:member_id>")
@login_required
def talk_redirect(member_id: int):
"""The old per-conversation address, pointed at the person's page.
By id, because that is what the old links carry; everything written from now
on uses the login, which is the same address as their public page.
"""
other = get_db().execute(
"SELECT gitea_login FROM members WHERE id = ? AND role != 'tombstone'",
(member_id,),
).fetchone()
if other is None:
abort(404)
return redirect(url_for("members.show", login=other["gitea_login"]))
@bp.route("/privados/con/<int:member_id>", methods=["POST"])
@login_required
def talk(member_id: int):
"""Send one message. The reading half is `history()`, on the member page.
POST only. There used to be a GET here rendering the whole conversation;
that page is now the person's page, and leaving a GET behind would have
meant two addresses rendering the same thing, drifting apart.
"""
if member_id == g.member["id"]:
abort(400)
db = get_db()
other = db.execute(
"""SELECT * FROM members
WHERE id = ? AND active = 1 AND role != 'tombstone'""",
(member_id,),
).fetchone()
if other is None:
abort(404)
if blocked_between(g.member["id"], member_id):
abort(403)
body = request.form.get("body", "").strip()[:BODY_MAX]
try:
staged = uploads.stage(request.files.getlist("pictures"))
except uploads.RejectedUpload as exc:
flash(str(exc), "error")
return redirect(_back_to(other))
if not body and not staged:
flash("Escribe algo o adjunta una imagen.", "error")
return redirect(_back_to(other))
# Only now does the conversation come into being.
conversation_id = existing_conversation(member_id) or conversation_with(member_id)
cursor = db.execute(
"INSERT INTO messages (conversation_id, author_id, body_md) VALUES (?, ?, ?)",
(conversation_id, g.member["id"], body),
)
uploads.save(staged, g.member["id"], message_id=cursor.lastrowid)
return redirect(_back_to(other, "#final"))
@bp.route("/privados/bloquear/<int:member_id>", methods=["POST"])
@ -229,13 +244,18 @@ def talk(member_id: int):
def block(member_id: int):
if member_id == g.member["id"]:
abort(400)
other = get_db().execute(
"SELECT * FROM members WHERE id = ? AND role != 'tombstone'", (member_id,)
).fetchone()
if other is None:
abort(404)
get_db().execute(
"""INSERT INTO blocks (blocker_id, blocked_id) VALUES (?, ?)
ON CONFLICT DO NOTHING""",
(g.member["id"], member_id),
)
flash("Bloqueado. Ninguno de los dos puede escribir al otro.", "ok")
return redirect(url_for("messages.inbox"))
return redirect(_back_to(other))
@bp.route("/privados/desbloquear/<int:member_id>", methods=["POST"])
@ -243,7 +263,12 @@ def block(member_id: int):
def unblock(member_id: int):
"""Only your own block. Removing somebody else's would let the blocked
person undo the thing that was done to protect against them."""
other = get_db().execute(
"SELECT * FROM members WHERE id = ? AND role != 'tombstone'", (member_id,)
).fetchone()
if other is None:
abort(404)
get_db().execute("DELETE FROM blocks WHERE blocker_id = ? AND blocked_id = ?",
(g.member["id"], member_id))
flash("Desbloqueado.", "ok")
return redirect(url_for("messages.inbox"))
return redirect(_back_to(other))

View File

@ -511,9 +511,26 @@ input[type="file"] {
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-sm);
padding: 1rem;
/* No padding of its own: the whole card is one link, and the padding lives
on the anchor so that a click an eighth of an inch from the name still
opens the page. */
padding: 0;
}
.person-card--off { opacity: 0.55; }
.person-card__link {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem;
border-radius: var(--radius-lg);
color: inherit;
text-decoration: none;
}
.person-card__link:hover,
.person-card__link:focus-visible {
background: var(--brand-softer);
}
.person-card__link:hover .person-card__name { color: var(--brand-dark); }
.person-card__head { display: flex; align-items: center; gap: 0.75rem; }
.person-card__photo {
width: 56px;
@ -532,22 +549,44 @@ input[type="file"] {
font-size: 1.4rem;
font-weight: 700;
}
.person-card__who { min-width: 0; } /* so a long name wraps instead of pushing */
.person-card__name { margin: 0; font-size: 1.05rem; }
/* min-width so a long name wraps instead of pushing the card wider; the spans
are blocks because the name and the line under it are two lines, and a card
this small does not need a heading element to say so. */
.person-card__who { display: block; min-width: 0; }
.person-card__who > span { display: block; }
.person-card__name { margin: 0; font-size: 1.05rem; font-weight: 600; }
.person-card__name .muted { font-weight: 400; }
.person-card__who p { margin: 0.15rem 0 0; }
.person-card__bio {
margin: 0.75rem 0 0;
color: var(--muted);
font-size: 0.9rem;
/* --- one person's page ------------------------------------------------- */
.person-head { display: flex; align-items: flex-start; gap: 1rem; }
.person-head__photo {
width: 88px;
height: 88px;
flex: 0 0 88px;
border-radius: 50%;
object-fit: cover;
border: 1px solid var(--border-light);
}
.person-card__foot {
.person-head__photo--none {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
margin-top: 0.75rem;
align-items: center;
justify-content: center;
background: var(--brand-soft);
color: var(--brand-dark);
font-size: 2rem;
font-weight: 700;
}
.person-card__admin { margin-top: 0.75rem; border-top: 1px solid var(--border-light); padding-top: 0.5rem; }
.person-head__who { min-width: 0; }
.person-head__who > :first-child { margin-top: 0; }
.person-head__links { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.person-head__foot { margin: 0.75rem 0 0; }
.section-title { margin: 1.5rem 0 0.25rem; font-size: 1.1rem; }
.person-block { margin-top: 1.25rem; }
.person-block summary { cursor: pointer; color: var(--subtle); font-size: 0.85rem; }
.person-block p { margin: 0.5rem 0; }
.person-card__admin { margin-top: 1.25rem; border-top: 1px solid var(--border-light); padding-top: 0.5rem; }
.person-card__admin summary {
cursor: pointer;
color: var(--subtle);

View File

@ -1,12 +1,20 @@
{# A member's name, as a link to their page when they have one.
{# A member's name, as a link to their page inside the members area.
The rule is in one place because it is easy to get wrong in two directions:
a name that never links makes the profiles invisible, and a name that always
links sends people to a 404 for everybody who has not published theirs. So
every screen calls this, and none of them has to remember. #}
{% macro person(name, login=None, published=False) %}
{%- if published and login -%}
<a class="who-link" href="{{ url_for('profiles_public.show', name=login) }}">{{ name }}</a>
It used to link to their *public* page, and only when they had published one
— which meant most names on the wall were plain text, and there was no way to
get from somebody's post to writing to them. Every template that calls this
is behind the login, so the link now goes to /comunidad/miembro/<usuario>,
which exists for every member: who they are, what the two of you have written
each other, and a link out to their public page when they have published one.
The rule stays in one place because it is easy to get wrong in two
directions: a name that never links makes the people invisible, and a name
that always links sends somebody to a 404. The one name with no page is the
tombstone that an erased member's writing is reassigned to — it is not a
person and has nothing to show. #}
{% macro person(name, login=None) %}
{%- if login and login != tombstone_login -%}
<a class="who-link" href="{{ url_for('members.show', login=login) }}">{{ name }}</a>
{%- else -%}
{{ name }}
{%- endif -%}

View File

@ -36,17 +36,23 @@
{% if g.member %}
<nav class="site-bar__pages" aria-label="Secciones">
{# Five entries, and four of them are the same for everybody. The role
{# Six entries, and five of them are the same for everybody. The role
only decides whether Gestión is there — it used to decide three of
them, which is how an ordinary member ended up signing in to a wall
and a member list with their own profile and their own private
messages hidden from them. Account items are in the corner menu
above, because "Mi perfil" is not a section of the site. #}
above, because "Mi perfil" is not a section of the site.
*Privados* used to be here, holding a list of conversations. The
people are the section now and the messages live on each person's
page, so the unread badge hangs on Miembros: it is the only thing
left that tells a member somebody wrote to them, which is why it is
also repeated on the card of whoever wrote. #}
<ul class="page-nav">
<li><a href="{{ url_for('home.index') }}">Inicio</a></li>
<li><a href="{{ url_for('board.threads') }}">Muro</a></li>
<li>
<a href="{{ url_for('messages.inbox') }}">Privados{% set unread = unread_private() %}{% if unread %} <span class="tag">{{ unread }}</span>{% endif %}</a>
<a href="{{ url_for('members.index') }}">Miembros{% set unread = unread_private() %}{% if unread %} <span class="tag">{{ unread }}</span>{% endif %}</a>
</li>
<li>
{# The badge counts what is waiting for a moderator, so for
@ -75,7 +81,6 @@
<footer class="site-foot">
<a href="/">Ir al sitio público</a>
{% if g.member %} · <a href="{{ url_for('members.index') }}">Miembros</a>{% endif %}
<div class="site-foot__legal">Viena Latina © {{ current_year }} · Área privada</div>
</footer>
</div>

View File

@ -1,54 +0,0 @@
{% extends "base.html" %}
{% from "_person.html" import person %}
{% from "_attachments.html" import attachments %}
{% block title %}{{ other.display_name }}{% endblock %}
{% block main %}
<div class="feed-head">
<h1>{{ person(other.display_name, other.gitea_login, other.profile_published) }}</h1>
<a class="linkish" href="{{ url_for('messages.inbox') }}">Volver</a>
</div>
{% for m in messages %}
<article class="card card--comment">
<div class="card__meta">
<span>{{ person(m.author, m.author_login, m.author_published) }}</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=other.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>
{% else %}
{# Always on this page, under the history. There is no separate step to "open"
a conversation: arriving at somebody's name is opening it, and nothing is
created in the database until the first message is actually sent. #}
<form class="card" method="post" enctype="multipart/form-data"
action="{{ url_for('messages.talk', member_id=other.id) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<label for="body">Mensaje</label>
<textarea id="body" data-markdown name="body" rows="4" autofocus
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>
{% endif %}
{% endblock %}

View File

@ -15,14 +15,16 @@
<section class="panel">
<div class="panel__head">
<h2>Miembros</h2>
<a class="linkish" href="{{ url_for('members.index') }}">Abrir</a>
<a class="linkish" href="{{ url_for('members.new') }}">Dar de alta</a>
</div>
<p class="panel__row">
{{ counts.members }} en total · {{ counts.moderators }} pueden moderar
{% if counts.suspended %} · {{ counts.suspended }} suspendido{{ '' if counts.suspended == 1 else 's' }}{% endif %}
</p>
<p class="muted small">
Dar de alta, invitar de nuevo, cambiar el rol, suspender y eliminar.
El directorio está en <a href="{{ url_for('members.index') }}">Miembros</a>,
que ahora es una sección como las demás. Invitar de nuevo, cambiar el rol,
suspender y eliminar están en la ficha de cada persona.
</p>
</section>

View File

@ -19,7 +19,7 @@
{% for item in queue %}
<p class="panel__row">
<a href="{{ url_for('submissions.show', submission_id=item.id) }}">{{ item.title }}</a>
<span class="muted small">{{ person(item.author, item.author_login, item.author_published) }} · {{ item.created_at }}</span>
<span class="muted small">{{ person(item.author, item.author_login) }} · {{ item.created_at }}</span>
</p>
{% endfor %}
</section>
@ -28,14 +28,14 @@
<section class="panel">
<div class="panel__head">
<h2>Privados</h2>
<a class="linkish" href="{{ url_for('messages.inbox') }}">Todos</a>
<a class="linkish" href="{{ url_for('members.index') }}">Miembros</a>
</div>
{% if not conversations %}
<p class="muted">Todavía no tienes conversaciones. Escribe a alguien desde Privados.</p>
<p class="muted">Todavía no tienes conversaciones. Abre la ficha de alguien en Miembros y escríbele.</p>
{% endif %}
{% for c in conversations %}
<p class="panel__row">
<a href="{{ url_for('messages.talk', member_id=c.other_id) }}">{{ c.other_name }}</a>
<a href="{{ url_for('members.show', login=c.other_login) }}">{{ c.other_name }}</a>
{% if c.unread %}<span class="tag">{{ c.unread }}</span>{% endif %}
{% if c.last_at %}<span class="muted small">{{ c.last_at }}</span>{% endif %}
</p>
@ -53,7 +53,7 @@
{% for t in threads %}
<p class="panel__row">
<a href="{{ url_for('board.thread', thread_id=t.id) }}">{{ t.title }}</a>
<span class="muted small">{{ person(t.author, t.author_login, t.author_published) }} · {{ t.replies }} respuesta{{ '' if t.replies == 1 else 's' }}</span>
<span class="muted small">{{ person(t.author, t.author_login) }} · {{ t.replies }} respuesta{{ '' if t.replies == 1 else 's' }}</span>
</p>
{% endfor %}
</section>

View File

@ -1,44 +0,0 @@
{% extends "base.html" %}
{% block title %}Privados{% endblock %}
{% block main %}
<div class="feed-head">
<h1>Mensajes privados</h1>
</div>
{% if people %}
{# GET, not POST: choosing somebody to write to is navigation, not a change.
It also means no conversation is created just because a name was picked. #}
<form class="card" method="get" action="{{ url_for('messages.pick') }}">
<label for="para">Escribir a</label>
<select id="para" name="member_id">
{% for person in people %}
<option value="{{ person.id }}">{{ person.display_name }}</option>
{% endfor %}
</select>
<button class="btn" type="submit">Escribir</button>
</form>
{% endif %}
{% if not conversations %}
<p class="muted">Todavía no tienes conversaciones privadas.</p>
{% endif %}
{% for c in conversations %}
<article class="card">
<a class="card__title" href="{{ url_for('messages.talk', member_id=c.other_id) }}">
{{ c.other_name }}
{% if c.unread %}<span class="tag">{{ c.unread }}</span>{% endif %}
</a>
<p class="muted small">{{ excerpt(c.last_body) or 'Sin mensajes todavía.' }}</p>
<div class="card__meta">
{% if c.last_at %}<time>{{ c.last_at }}</time>{% endif %}
<form method="post" action="{{ url_for('messages.block', member_id=c.other_id) }}"
data-confirm="Al bloquear a {{ c.other_name }} 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>
</div>
</article>
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,204 @@
{# 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 %}
{% set is_owner = me.role == 'owner' %}
{% set is_admin = me.role in ('owner', 'admin') %}
{% 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 != '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 is_owner or member.role != '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">
<option value="user" {{ 'selected' if member.role == 'user' }}>Miembro</option>
<option value="moderator" {{ 'selected' if member.role == 'moderator' }}>Moderador</option>
{% if is_owner %}
<option value="admin" {{ 'selected' if member.role == 'admin' }}>Administrador</option>
{% endif %}
</select>
<button class="linkish" type="submit">Cambiar rol</button>
</form>
{% endif %}
{% if is_owner %}
{% if member.role == 'admin' and member.active %}
<form method="post" action="{{ url_for('members.transfer', member_id=member.id) }}"
data-confirm="Vas a dejar de ser el responsable y {{ member.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=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 %}

View File

@ -1,9 +1,7 @@
{% 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 %}
@ -14,15 +12,20 @@
{% 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. #}
<p class="muted">
Abre la ficha de alguien para escribirle en privado y leer lo que os habéis
escrito. Los mensajes privados viven en la ficha de cada persona; no hay
bandeja aparte.
</p>
{# Faces and names, and the whole card is the link. This was a page of cards
each carrying a bio, a couple of links and a fold-out admin panel — four
things to read per person, on a page whose job is to let you find one. All of
that is on the person's own page now. #}
<ul class="people">
{% for m in members %}
<li class="person-card {{ '' if m.active else 'person-card--off' }}">
<div class="person-card__head">
<a class="person-card__link" href="{{ url_for('members.show', login=m.gitea_login) }}">
{% if m.photo_name %}
<img class="person-card__photo"
src="{{ url_for('profiles.member_photo', stored_name=m.photo_name) }}"
@ -35,96 +38,26 @@
</span>
{% endif %}
<div class="person-card__who">
<h2 class="person-card__name">
{{ person(m.display_name, m.gitea_login, m.profile_published) }}
<span class="person-card__who">
<span class="person-card__name">
{{ m.display_name }}
{% if m.id == me.id %}<span class="muted small">(tú)</span>{% endif %}
</h2>
{% if m.unread %}
{# Who wrote, not just that somebody did — and the cards are
sorted so this one is at the top of the page. #}
<span class="tag" aria-label="{{ m.unread }} sin leer">{{ m.unread }}</span>
{% endif %}
</span>
{# 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">
The email stays on their page, inside the admin block. #}
<span 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 %}
</span>
</span>
</a>
</li>
{% endfor %}
</ul>
@ -132,9 +65,9 @@
{% 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.
administradores dan de alta miembros y moderadores. Suspender, cambiar el rol,
reenviar la invitación y eliminar están en la ficha de cada persona, bajo
«Gestionar».
</p>
{% endif %}
{% endblock %}

View File

@ -11,7 +11,7 @@
<article class="card">
<div class="card__meta">
<span class="tag tag--{{ item.state }}">{{ labels[item.state] }}</span>
<span>{{ person(item.author, item.author_login, item.author_published) }}</span> · <time>{{ item.created_at }}</time>
<span>{{ person(item.author, item.author_login) }}</span> · <time>{{ item.created_at }}</time>
{% if item.categories %} · <span>{{ item.categories }}</span>{% endif %}
</div>
{% if item.description %}<p class="muted">{{ item.description }}</p>{% endif %}

View File

@ -36,7 +36,7 @@
{% for item in queue %}
<article class="card">
<div class="card__meta">
<span>{{ person(item.author, item.author_login, item.author_published) }}</span> · <time>{{ item.created_at }}</time>
<span>{{ person(item.author, item.author_login) }}</span> · <time>{{ item.created_at }}</time>
</div>
<h3 class="card__title">
<a href="{{ url_for('submissions.show', submission_id=item.id) }}">{{ item.title }}</a>

View File

@ -9,7 +9,7 @@
<div class="card__meta">
{% if thread.pinned %}<span class="tag">Fijado</span>{% endif %}
{% if thread.locked %}<span class="tag tag--quiet">Cerrado</span>{% endif %}
<span>{{ person(author.display_name, author.gitea_login, author.profile_published) }}</span> · <time>{{ thread.created_at }}</time>
<span>{{ person(author.display_name, author.gitea_login) }}</span> · <time>{{ thread.created_at }}</time>
{% if thread.edited_at %}<span class="muted small">(editado)</span>{% endif %}
</div>
<h1 class="card__title">{{ thread.title }}</h1>
@ -51,7 +51,7 @@
{% for c in comments %}
<article class="card card--comment" id="c{{ c.id }}">
<div class="card__meta">
<span>{{ person(c.author, c.author_login, c.author_published) }}</span> · <time>{{ c.created_at }}</time>
<span>{{ person(c.author, c.author_login) }}</span> · <time>{{ c.created_at }}</time>
{% if c.edited_at %}<span class="muted small">(editado)</span>{% endif %}
</div>
<div class="prose">{{ to_html(c.body_md) }}</div>

View File

@ -20,7 +20,7 @@
<div class="card__meta">
{% if t.pinned %}<span class="tag">Fijado</span>{% endif %}
{% if t.locked %}<span class="tag tag--quiet">Cerrado</span>{% endif %}
<span>{{ person(t.author, t.author_login, t.author_published) }}</span> · <time>{{ t.created_at }}</time>
<span>{{ person(t.author, t.author_login) }}</span> · <time>{{ t.created_at }}</time>
</div>
<h2 class="card__title">
<a href="{{ url_for('board.thread', thread_id=t.id) }}">{{ t.title }}</a>

View File

@ -180,19 +180,26 @@ def test_erasing_a_member_keeps_their_threads_readable(app, db, post, owner_id,
assert row["display_name"] == "Miembro eliminado"
def test_the_member_list_renders_for_each_role(client, db, owner_id, make_member, sign_in):
"""Every role takes a different branch through members.html — the owner
sees transfer and erase, an admin sees suspend, a user sees neither — so
each one is rendered here rather than trusted."""
def test_the_member_page_renders_for_each_role(client, db, owner_id, make_member, sign_in):
"""Every role takes a different branch through member.html — the owner sees
transfer and erase, an admin sees suspend, a plain member sees neither — so
each one is rendered here rather than trusted.
These controls used to be on the cards in the directory and are on the
person's page now, which is what this looks at. The owner's branch needs an
admin to transfer to, so the page opened is the admin's.
"""
admin_id = make_member("admina", role="admin")
user_id = make_member("usuaria")
for member_id, expected in ((owner_id, "Transferir titularidad"),
(admin_id, "Suspender"),
(user_id, None)):
(make_member("usuaria"), None)):
sign_in(member_id)
body = client.get("/comunidad/miembros").get_data(as_text=True)
assert "usuaria" in body
# Never your own page: nobody manages themselves, so the block is not
# drawn there and the test would pass for the wrong reason.
who = "usuaria" if member_id == admin_id else "admina"
body = client.get(f"/comunidad/miembro/{who}").get_data(as_text=True)
assert who.title() in body
if expected:
assert expected in body
else:
@ -353,15 +360,16 @@ def test_erasing_a_member_lets_the_name_be_used_again(
"SELECT 1 FROM members WHERE gitea_login = 'salvador'").fetchone() is not None
# --- the directory --------------------------------------------------------
# --- the directory and the page -------------------------------------------
#
# Miembros used to be a five-column admin table whose last column held four
# forms, wrapping on top of each other. It is a directory now: everybody sees
# the people, admins open a per-card block for the controls. Both halves are
# asserted, because "the table is gone" is only an improvement if the controls
# came with it.
# forms, wrapping on top of each other; then it was cards, each carrying a bio,
# some links and a fold-out admin block. It is faces and names now, and
# everything about one person — their profile, the conversation with them, and
# the controls — is on their own page. Both halves are asserted, because "the
# cards are simpler" is only an improvement if nothing was lost on the way.
def test_everybody_sees_the_people(client, db, make_member, sign_in):
def test_the_directory_is_faces_and_names(client, db, make_member, sign_in):
maria = make_member("maria")
db.execute("UPDATE members SET bio = ? WHERE id = ?",
("Vivo en Ottakring.\nSegunda línea.", maria))
@ -370,33 +378,57 @@ def test_everybody_sees_the_people(client, db, make_member, sign_in):
body = client.get("/comunidad/miembros").get_data(as_text=True)
assert "Maria" in body and "maria" in body
assert "/comunidad/miembro/maria" in body # the card is the way in
# The bio is on their page. A grid whose job is to let you find one person
# should not be four lines of reading each.
assert "Vivo en Ottakring." not in body
def test_their_page_is_who_they_are_and_where_you_write(client, db, make_member, sign_in):
maria = make_member("maria")
db.execute("UPDATE members SET bio = ?, links = ? WHERE id = ?",
("Vivo en Ottakring.", '[{"label": "Mi web", "url": "https://ejemplo.at"}]',
maria))
sign_in(make_member("otra"))
body = client.get("/comunidad/miembro/maria").get_data(as_text=True)
assert "Vivo en Ottakring." in body
assert "Segunda línea." not in body # the first line only, as a summary
assert f'/comunidad/privados/con/{maria}' in body # somewhere to write from
assert 'href="https://ejemplo.at"' in body and 'rel="nofollow noopener"' in body
assert f'action="/comunidad/privados/con/{maria}"' in body # the write box
assert "No ha publicado una página pública." in body
def test_a_plain_member_sees_no_controls_and_no_addresses(client, make_member, sign_in):
make_member("maria")
sign_in(make_member("otra"))
body = client.get("/comunidad/miembros").get_data(as_text=True)
for url in ("/comunidad/miembros", "/comunidad/miembro/maria"):
body = client.get(url).get_data(as_text=True)
for control in ("Gestionar", "Suspender", "Cambiar rol", "Eliminar",
"Enviar invitación", "maria@example.com"):
assert control not in body, control
assert control not in body, f"{control} in {url}"
def test_an_admin_keeps_every_control(client, make_member, sign_in):
make_member("maria")
sign_in(make_member("admina", role="admin"))
body = client.get("/comunidad/miembros").get_data(as_text=True)
body = client.get("/comunidad/miembro/maria").get_data(as_text=True)
for control in ("Gestionar", "Suspender", "Cambiar rol", "Enviar invitación",
"maria@example.com"):
assert control in body, control
assert "Eliminar" not in body # erasure is the owner's alone
# And none of it leaks back onto the directory, which is where it was.
# Asserted on the forms rather than the words: the grid's footnote says in
# so many words that the controls are under «Gestionar» on each page, which
# is the sentence that sends an admin to the right place.
grid = client.get("/comunidad/miembros").get_data(as_text=True)
assert "/estado" not in grid and "/rol" not in grid
assert "maria@example.com" not in grid
def test_a_photo_shows_inside_even_when_the_page_is_not_published(
app, client, db, make_member, sign_in):
@ -430,3 +462,18 @@ def test_the_members_area_photo_needs_a_session(app, client, db, make_member):
assert response.status_code == 302
assert "/login" in response.headers["Location"]
def test_a_moderator_gets_no_controls_either(client, make_member, sign_in):
"""A moderator curates content, not people. The block is hidden from them
and the routes refuse them, which is the half that matters."""
maria = make_member("maria")
sign_in(make_member("luisa", role="moderator"))
body = client.get("/comunidad/miembro/maria").get_data(as_text=True)
assert "Gestionar" not in body
assert client.get("/comunidad/miembros/nuevo").status_code == 403
assert client.post(f"/comunidad/miembros/{maria}/estado",
data={"csrf_token": "token-for-tests", "active": "0"}
).status_code == 403

View File

@ -1,12 +1,17 @@
"""Private messages, unread marks and blocking.
A conversation is addressed by the person, not by an id: `/privados/con/<id>`
is "what I have said to them and they to me", and it exists as a page before it
exists as a row. That makes the access rule structural rather than checked — a
lookup is always scoped to the member doing the looking, so there is no query
that could return somebody else's correspondence. The tests below still come at
it from the outside, because the failure mode here is not an error, it is
somebody quietly reading what is not theirs.
A conversation is addressed by the person and read on their page:
`/comunidad/miembro/<usuario>` is "who they are, and what I have said to them
and they to me", and it exists as a page before it exists as a row. That makes
the access rule structural rather than checked — a lookup is always scoped to
the member doing the looking, so there is no query that could return somebody
else's correspondence. The tests below still come at it from the outside,
because the failure mode here is not an error, it is somebody quietly reading
what is not theirs.
Sending is a POST of its own (`/privados/con/<id>`), which is why the two
helpers below are separate: `page` is where a conversation is read, `send` is
the only thing that writes to one.
"""
from __future__ import annotations
@ -17,7 +22,13 @@ from pathlib import Path
PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 64
def talk(member_id: int) -> str:
def page(login: str) -> str:
"""Where the conversation with somebody is read: their page."""
return f"/comunidad/miembro/{login}"
def send(member_id: int) -> str:
"""Where a message is posted. By id, as the form on that page does."""
return f"/comunidad/privados/con/{member_id}"
@ -27,49 +38,50 @@ def test_a_third_person_sees_their_own_empty_conversation(
client, post, make_member, sign_in):
"""The old design gave conversations their own ids, so this test had to
check that a stranger opening one got a 404. Addressing by person removes
the question: `/privados/con/<jose>` means *my* conversation with José, so
a third person opening the same URL sees an empty page, not this one."""
the question: José's page shows *my* conversation with José, so a third
person opening the same URL sees his page with an empty conversation on it,
not this one."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Algo privado"})
post(send(jose), {"body": "Algo privado"})
sign_in(make_member("curiosa"))
page = client.get(talk(jose))
response = client.get(page("jose"))
assert page.status_code == 200
assert "Algo privado" not in page.get_data(as_text=True)
assert response.status_code == 200
assert "Algo privado" not in response.get_data(as_text=True)
def test_writing_to_somebody_does_not_join_you_to_their_other_conversations(
client, db, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Para José"})
post(send(jose), {"body": "Para José"})
curiosa = make_member("curiosa")
sign_in(curiosa)
post(talk(jose), {"body": "Para José también"})
post(send(jose), {"body": "Para José también"})
# Two separate conversations, and neither shows the other's messages.
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 2
assert "Para José" not in client.get(talk(jose)).get_data(as_text=True).replace(
assert "Para José" not in client.get(page("jose")).get_data(as_text=True).replace(
"Para José también", "")
def test_the_two_parties_see_it(client, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Hola José"})
post(send(jose), {"body": "Hola José"})
sign_in(jose)
assert "Hola José" in client.get(talk(maria)).get_data(as_text=True)
assert "Hola José" in client.get(page("maria")).get_data(as_text=True)
def test_writing_twice_reuses_the_one_conversation(client, db, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Una"})
post(talk(jose), {"body": "Dos"})
post(send(jose), {"body": "Una"})
post(send(jose), {"body": "Dos"})
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 1
assert db.execute("SELECT COUNT(*) AS n FROM messages").fetchone()["n"] == 2
@ -84,63 +96,108 @@ def test_the_box_is_there_before_anything_has_been_said(
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
page = client.get(talk(jose))
response = client.get(page("jose"))
assert page.status_code == 200
body = page.get_data(as_text=True)
assert response.status_code == 200
body = response.get_data(as_text=True)
assert 'name="body"' in body # the textarea, on first arrival
assert "Todavía no os habéis escrito" in body
def test_merely_looking_creates_nothing(client, db, make_member, sign_in):
"""Otherwise the inbox fills with "Sin mensajes todavía" for every name
somebody was curious about."""
"""Looking at somebody's page is not writing to them, and a directory of
faces means a page gets opened out of curiosity all the time."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
client.get(talk(jose))
client.get(page("jose"))
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 0
def test_the_picker_sends_you_straight_there(client, make_member, sign_in):
# --- the addresses that moved ---------------------------------------------
def test_the_old_section_still_leads_somewhere(client, make_member, sign_in):
"""*Privados* was a section for months. A bookmark to it lands on the
directory rather than on a 404."""
sign_in(make_member("maria"))
response = client.get("/comunidad/privados")
assert response.status_code == 302
assert response.headers["Location"].endswith("/comunidad/miembros")
def test_an_old_conversation_link_lands_on_the_person(client, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
response = client.get(f"/comunidad/privados/con?member_id={jose}")
response = client.get(f"/comunidad/privados/con/{jose}")
assert response.status_code == 302
assert response.headers["Location"].endswith(f"/privados/con/{jose}")
assert response.headers["Location"].endswith("/comunidad/miembro/jose")
def test_you_cannot_write_to_yourself(client, make_member, sign_in):
def test_your_own_page_has_no_conversation_on_it(client, make_member, sign_in):
"""It is a real page — it is how you see what the others see — but there is
nothing to say to yourself and nothing to mark read."""
maria = make_member("maria")
sign_in(maria)
assert client.get(talk(maria)).status_code == 400
body = client.get(page("maria")).get_data(as_text=True)
assert 'name="body"' not in body
assert "Esta es tu ficha" in body
def test_you_cannot_write_to_somebody_who_is_not_a_member(client, make_member, sign_in):
def test_you_cannot_write_to_yourself(client, post, make_member, sign_in):
maria = make_member("maria")
sign_in(maria)
assert post(send(maria), {"body": "Hola yo"}).status_code == 400
def test_you_cannot_write_to_somebody_who_is_not_a_member(
client, post, make_member, sign_in):
sign_in(make_member("maria"))
assert client.get(talk(9999)).status_code == 404
assert post(send(9999), {"body": "Hola"}).status_code == 404
assert client.get(page("nadie")).status_code == 404
# --- unread ---------------------------------------------------------------
def test_unread_is_per_member_and_clears_on_reading(client, post, make_member, sign_in):
"""The badge is on *Miembros* now, and on the card of whoever wrote. Both
come from the same two numbers, so this is also the test that the directory
counts per person rather than in total."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "¿Vienes?"})
post(send(jose), {"body": "¿Vienes?"})
badge = '<span class="tag">1</span>'
# The sender has nothing unread — their own message does not count.
assert badge not in client.get("/comunidad/privados").get_data(as_text=True)
assert badge not in client.get("/comunidad/miembros").get_data(as_text=True)
sign_in(jose)
assert badge in client.get("/comunidad/privados").get_data(as_text=True)
assert badge in client.get("/comunidad/miembros").get_data(as_text=True)
client.get(talk(maria)) # opening marks it read
assert badge not in client.get("/comunidad/privados").get_data(as_text=True)
client.get(page("maria")) # opening marks it read
assert badge not in client.get("/comunidad/miembros").get_data(as_text=True)
def test_the_person_who_wrote_is_at_the_top(client, post, make_member, sign_in):
"""Without this the directory is alphabetical and the person waiting for an
answer is wherever the alphabet put them — which is the one thing the old
inbox did that a grid of faces does not."""
make_member("ana") # sorts first by name, nothing unread
maria, zoe = make_member("maria"), make_member("zoe")
sign_in(zoe)
post(send(maria), {"body": "¿Vienes?"})
sign_in(maria)
body = client.get("/comunidad/miembros").get_data(as_text=True)
assert body.index("/comunidad/miembro/zoe") < body.index("/comunidad/miembro/ana")
# --- blocking -------------------------------------------------------------
@ -151,12 +208,12 @@ def test_a_block_stops_both_directions(client, post, make_member, sign_in):
safety feature."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Hola"})
post(send(jose), {"body": "Hola"})
post(f"/comunidad/privados/bloquear/{jose}") # maria blocks jose
assert post(talk(jose), {"body": "Otra cosa"}).status_code == 403 # …and maria too
assert post(send(jose), {"body": "Otra cosa"}).status_code == 403 # …and maria too
sign_in(jose)
assert post(talk(maria), {"body": "¿Hola?"}).status_code == 403
assert post(send(maria), {"body": "¿Hola?"}).status_code == 403
def test_a_block_is_enforced_in_the_handler_not_the_template(
@ -168,17 +225,17 @@ def test_a_block_is_enforced_in_the_handler_not_the_template(
post(f"/comunidad/privados/bloquear/{maria}")
sign_in(maria) # never reloaded the page, still has the form
assert post(talk(jose), {"body": "Hola"}).status_code == 403
assert post(send(jose), {"body": "Hola"}).status_code == 403
def test_a_blocked_person_still_sees_the_history_but_no_box(
client, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Antes del bloqueo"})
post(send(jose), {"body": "Antes del bloqueo"})
post(f"/comunidad/privados/bloquear/{jose}")
body = client.get(talk(jose)).get_data(as_text=True)
body = client.get(page("jose")).get_data(as_text=True)
assert "Antes del bloqueo" in body
assert 'name="body"' not in body
assert "bloqueo entre vosotros" in body
@ -197,12 +254,18 @@ def test_unblocking_only_removes_your_own(client, db, post, make_member, sign_in
assert db.execute("SELECT COUNT(*) AS n FROM blocks").fetchone()["n"] == 1
def test_a_blocked_person_is_not_offered_in_the_list(client, post, make_member, sign_in):
def test_a_blocked_person_is_still_in_the_directory(client, post, make_member, sign_in):
"""A deliberate change. The old inbox had a picker of people you could
write to, and a blocked person was left out of it. The directory is not a
picker — it is the list of who is in the association, and somebody you have
blocked has not left. The block is stated on their page, where the write
box would have been."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(f"/comunidad/privados/bloquear/{jose}")
assert "Jose" not in client.get("/comunidad/privados").get_data(as_text=True)
assert "Jose" in client.get("/comunidad/miembros").get_data(as_text=True)
assert "bloqueo entre vosotros" in client.get(page("jose")).get_data(as_text=True)
# --- pictures -------------------------------------------------------------
@ -213,7 +276,7 @@ def test_a_picture_in_a_message_is_private_to_the_two_of_them(
signed in is nowhere near enough of a check."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Mira", "pictures": (io.BytesIO(PNG), "foto.png")},
post(send(jose), {"body": "Mira", "pictures": (io.BytesIO(PNG), "foto.png")},
content_type="multipart/form-data")
name = db.execute("SELECT stored_name FROM attachments").fetchone()["stored_name"]
@ -229,7 +292,7 @@ def test_a_picture_in_a_message_is_private_to_the_two_of_them(
def test_an_empty_message_with_no_picture_is_refused(client, db, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": " "})
post(send(jose), {"body": " "})
assert db.execute("SELECT COUNT(*) AS n FROM messages").fetchone()["n"] == 0
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 0
@ -244,7 +307,7 @@ def test_erasing_a_member_takes_their_private_messages(
somebody's erased correspondence is what erasure exists to prevent."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(talk(jose), {"body": "Privado", "pictures": (io.BytesIO(PNG), "f.png")},
post(send(jose), {"body": "Privado", "pictures": (io.BytesIO(PNG), "f.png")},
content_type="multipart/form-data")
name = db.execute("SELECT stored_name FROM attachments").fetchone()["stored_name"]
@ -268,3 +331,29 @@ def test_erasing_a_member_removes_blocks_either_way(
post(f"/comunidad/miembros/{maria}/eliminar")
assert db.execute("SELECT COUNT(*) AS n FROM blocks").fetchone()["n"] == 0
# --- where sending lands --------------------------------------------------
def test_sending_lands_back_on_their_page(client, post, make_member, sign_in):
"""The form posts by id and the page is addressed by login, so the redirect
is the one place the two have to agree."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
response = post(send(jose), {"body": "Hola"})
assert response.status_code == 302
assert response.headers["Location"].endswith("/comunidad/miembro/jose#final")
def test_a_suspended_member_has_a_page_but_no_box(client, post, make_member, sign_in):
"""They are in the directory, so their page has to exist; the handler
refuses a message to them, so the box is not drawn and the page says why."""
make_member("jose", active=0)
sign_in(make_member("maria"))
body = client.get(page("jose")).get_data(as_text=True)
assert "suspendido" in body
assert 'name="body"' not in body

View File

@ -1,7 +1,7 @@
"""What each role can see and reach.
This file exists because of a bug that no other test in this suite could have
caught: *Privados*, *Mi perfil* and *Contenido* were all inside one
caught: private messages, *Mi perfil* and *Contenido* were all inside one
`{% if g.member.role in ('owner', 'admin') %}` block in base.html, so an
ordinary member signed in to a wall and a member list and nothing else. Every
feature worked. Every test passed. Most of the members area was simply invisible
@ -21,7 +21,7 @@ import pytest
SECTIONS = {
"Inicio": "/comunidad/",
"Muro": "/comunidad/muro",
"Privados": "/comunidad/privados",
"Miembros": "/comunidad/miembros",
"Publicaciones": "/comunidad/publicaciones",
"Calendario": "/comunidad/calendario",
}
@ -39,7 +39,7 @@ def nav(client, sign_in):
@pytest.mark.parametrize("role", ["user", "moderator"])
def test_a_member_sees_the_four_shared_sections(role, nav, make_member):
def test_a_member_sees_the_five_shared_sections(role, nav, make_member):
"""The regression. Not one of these may depend on a role again."""
body = nav(make_member("maria", role=role))
for label in SECTIONS:
@ -176,7 +176,7 @@ def test_a_member_gets_their_name_and_their_sections(client, make_member, sign_i
assert state["signed_in"] is True
assert state["name"] == "Maria"
assert [s["label"] for s in state["sections"]] == [
"Inicio", "Muro", "Privados", "Publicaciones", "Calendario"]
"Inicio", "Muro", "Miembros", "Publicaciones", "Calendario"]
assert state["csrf"] # the bar renders a real logout form

View File

@ -219,30 +219,67 @@ def test_the_form_says_what_publishing_means(client, make_member, sign_in):
# --- names as doors -------------------------------------------------------
#
# A profile nobody can reach from inside the members area is a profile nobody
# visits. Every screen renders names through the one macro in
# templates/_person.html, which links only when there is a page to link to —
# the rule is in one place because both failures are silent: never linking
# hides the profiles, always linking sends people to a 404.
# Every screen renders names through the one macro in templates/_person.html,
# and it used to link to somebody's *public* page, only when they had published
# one — so most names on the wall were plain text and there was no way to get
# from a post to writing to its author. It links inside now, to
# /comunidad/miembro/<usuario>, which exists for every member; their public page
# is linked from there when they have one.
#
# The rule is in one place because both failures are silent: never linking
# hides the people, always linking sends somebody to a 404.
def test_a_name_on_the_wall_links_to_a_published_page(client, post, published, sign_in):
def test_a_name_on_the_wall_links_to_their_page_inside(client, post, published, sign_in):
author = published("maria")
sign_in(author)
post("/comunidad/nuevo", {"title": "Hola", "body": "Qué tal"})
for url in ("/comunidad/muro", "/comunidad/tema/1", "/comunidad/"):
assert 'href="/maria"' in client.get(url).get_data(as_text=True), url
assert ('href="/comunidad/miembro/maria"'
in client.get(url).get_data(as_text=True)), url
def test_a_name_without_a_page_is_not_a_link(client, post, published, sign_in):
def test_a_name_links_even_without_a_public_page(client, post, published, sign_in):
"""The change this phase makes. Somebody who has published nothing is still
somebody you can reach — and their page says in as many words that there is
no public one."""
author = published("maria", profile_published=0)
sign_in(author)
post("/comunidad/nuevo", {"title": "Hola", "body": "Qué tal"})
for url in ("/comunidad/muro", "/comunidad/tema/1"):
body = client.get(url).get_data(as_text=True)
assert 'href="/maria"' not in body, url
assert "Maria" in body, url # the name is still there
assert 'href="/comunidad/miembro/maria"' in body, url
assert 'href="/maria"' not in body, url # their public page is not there
page = client.get("/comunidad/miembro/maria").get_data(as_text=True)
assert 'href="/maria"' not in page
def test_their_page_links_out_to_the_public_one_when_there_is_one(
client, published, make_member, sign_in):
published("maria")
sign_in(make_member("jose"))
assert 'href="/maria"' in client.get("/comunidad/miembro/maria").get_data(as_text=True)
def test_an_erased_members_name_is_not_a_link(client, post, owner_id,
make_member, sign_in):
"""The one name with no page behind it. An erased member's writing is
reassigned to the tombstone, which is not a person and has nothing to
show — and `members.show` 404s for it, so a link there would be a dead
end on the wall."""
maria = make_member("maria")
sign_in(maria)
post("/comunidad/nuevo", {"title": "Hola", "body": "Qué tal"})
sign_in(owner_id)
post(f"/comunidad/miembros/{maria}/eliminar")
body = client.get("/comunidad/muro").get_data(as_text=True)
assert "Miembro eliminado" in body
assert "/comunidad/miembro/__removed__" not in body
def test_a_comment_and_a_private_message_link_too(client, post, published,
@ -256,6 +293,6 @@ def test_a_comment_and_a_private_message_link_too(client, post, published,
post("/comunidad/privados/con/%d" % jose, {"body": "Hola José"})
sign_in(jose)
assert 'href="/maria"' in client.get("/comunidad/tema/1").get_data(as_text=True)
assert 'href="/maria"' in client.get(
f"/comunidad/privados/con/{maria}").get_data(as_text=True)
link = 'href="/comunidad/miembro/maria"'
assert link in client.get("/comunidad/tema/1").get_data(as_text=True)
assert link in client.get("/comunidad/miembro/maria").get_data(as_text=True)

View File

@ -148,7 +148,7 @@ PROSE_BOXES = {
"thread_form.html": "body",
"comment_form.html": "body",
"thread.html": "body",
"conversation.html": "body",
"member.html": "body",
"submission_form.html": "body",
"content_form.html": "body",
"profile_edit.html": "bio",

View File

@ -672,13 +672,36 @@ Limits: 4 images per message, and `BOARD_UPLOAD_MAX_BYTES` (8MB by default)
each. Adding a picture to a post *after* publishing it means posting a reply —
editing changes the words, and leaves the pictures alone.
### 11.10 Private messages (`/comunidad/privados/`)
### 11.10 Private messages (on each person's page)
An inbox between two members: conversations, unread badges, photos, blocking.
Between two members: conversations, unread badges, photos, blocking.
Deliberately not live chat — that needs a connection held open per signed-in
member, which gunicorn's sync workers cannot do, and it would be the first
thing on this box with a real scaling limit.
**There is no inbox.** You write to somebody by opening their page —
`/comunidad/miembro/<usuario>`, reached from *Miembros* or from their name
anywhere on the wall — and the whole conversation with them is on it, under
their photo and bio, with the write box at the foot. One place per person
rather than a mailbox listing people.
Three consequences worth knowing:
* **The unread badge is on *Miembros***, and repeated on the card of whoever
wrote. Those cards are sorted so that anybody with something unread is at the
top of the grid — without that, the person waiting for an answer is wherever
the alphabet put them.
* **Opening the page marks it read.** There is no second step any more, so
there is no moment where the messages are on screen and still counted unread.
* **The old addresses redirect.** `/comunidad/privados` goes to the directory
and `/comunidad/privados/con/<id>` to that person's page; the POST that sends
a message is still `/comunidad/privados/con/<id>`, which is why the two look
alike in the logs.
A member's own page carries no conversation and no box: it is there so they can
see what the others see, and their own private messages are each on the page of
the person they had them with.
**Blocking is symmetric.** One block stops messages in both directions, and
either person can only remove their own. A block that silenced just the blocked
person would leave the blocker able to keep writing, which is a megaphone
@ -693,7 +716,7 @@ of the choice, and deliberate.
### 11.10b The members' bar on the public site
A signed-in member sees a slim bar above the public header on vienalatina.com,
with the same five sections the members area has. The public pages are files on
with the same sections the members area has. The public pages are files on
disk and get cached, so the bar is drawn in the browser:
`themes/vienalatina/assets/js/memberbar.js` asks `/comunidad/sesion.json` who is
reading, and that endpoint is the only thing that decides anything — a visitor
@ -800,7 +823,7 @@ the same problem the Gitea theme has. If the colours change in
`themes/vienalatina/assets/css/main.css`, change them in
`apps/board/templates/profile.html` too.
### 11.13 The five sections, and the moderation queue
### 11.13 The six sections, and the moderation queue
Signing in lands on **Inicio**, a dashboard of what has happened since the last
visit. The navigation is the same for everybody except the last entry:
@ -809,19 +832,26 @@ visit. The navigation is the same for everybody except the last entry:
|---|---|---|
| **Inicio** | `/comunidad/` | everybody |
| **Muro** | `/comunidad/muro` | everybody |
| **Privados** | `/comunidad/privados` | everybody |
| **Miembros** | `/comunidad/miembros` | everybody |
| **Publicaciones** | `/comunidad/publicaciones` | everybody, with two different pages behind it |
| **Calendario** | `/comunidad/calendario` | everybody; admins add events |
| **Gestión** | `/comunidad/gestion` | admins and the owner |
Gestión holds three things: Miembros, the published **Artículos**, and the
site's static **Páginas**. A moderator cannot open it, so their route to the
published articles is the *Ya publicado* link on Publicaciones — the only one
they have, which is why it sits beside the button rather than inside a
**Miembros replaced Privados**, which was a list of conversations. The people
are the section now — a grid of faces and names — and each person's page holds
their profile, the private conversation with them, and (for an admin) the
controls for that one person. §11.10 has the mechanics. The unread badge moved
to this entry with the messages.
Gestión holds Miembros' *Dar de alta*, the published **Artículos**, the site's
static **Páginas** and **Marca**. A moderator cannot open it, so their route to
the published articles is the *Ya publicado* link on Publicaciones — the only
one they have, which is why it sits beside the button rather than inside a
paragraph.
*Mi perfil*, *Descargar mis datos* and *Salir* are in the menu under the member's
own name, top right. They are not sections of the site, and while they were in the
navigation three of the five entries were admin-only — which meant an ordinary
navigation three of the entries were admin-only — which meant an ordinary
member signed in to a wall and a member list, with their own profile and their own
private messages hidden from them. `apps/board/tests/test_navigation.py` asserts
the navigation per role now, so that cannot come back quietly.
@ -866,18 +896,21 @@ only the title and the description. Editing a post keeps the author it already
had, so correcting somebody's typo never re-signs their article.
**On the wall itself**: one 👍 per member per post or comment, which clicking
again takes back, and every name is a link to that person's page — but only when
they have published one, so nobody is sent to a 404. Both rules live in one place
each (`templates/_reaction.html`, `templates/_person.html`) so no screen has to
again takes back, and every name is a link to that person's page inside the
members area — which exists for everybody, published page or not. The one name
that is not a link is *Miembro eliminado*, the tombstone an erased member's
writing is reassigned to. Both rules live in one place each
(`templates/_reaction.html`, `templates/_person.html`) so no screen has to
remember them.
**Miembros is a directory**, not an admin table: a card per person with their
photo, username, role, the first line of their bio, somewhere to write to them
and a link to their page. Admins get the controls — suspend, re-invite, change
role, erase — inside a *Gestionar* block on each card, closed by default. A
member's photo shows here even when their public page is unpublished, because
this side is behind the login; `profiles.member_photo` serves it and the profile
form says so in plain words.
**Miembros is a directory of faces and names**: a card per person with their
photo, username and role, and the whole card is a link to their page. Everything
about one person is on that page — their bio and links, the private conversation
with them, and, for an admin, the controls (suspend, re-invite, change role,
erase) inside a *Gestionar* block, closed by default. A member's photo shows
here even when their public page is unpublished, because this side is behind the
login; `profiles.member_photo` serves it and the profile form says so in plain
words.
### 11.15 The public menu is built from the pages