diff --git a/apps/board/content.py b/apps/board/content.py index 79ff3a8..d36609c 100644 --- a/apps/board/content.py +++ b/apps/board/content.py @@ -59,13 +59,6 @@ COLLECTIONS = { }, } -# The one category that changes what a post *is* rather than what it is about: -# tick it and the post needs a date of its own, appears in the agenda, renders -# with the date and the place at the top, and offers an .ics. -EVENT_CATEGORY = "Evento" - -CATEGORIES = ["Evento", "Turismo", "Cultura", "Gastronomía", "Comunidad", "Comercio"] - UPLOAD_FOLDER = "static/uploads" TITLE_MAX = 140 @@ -149,8 +142,6 @@ def frontmatter_for(collection: str, form: dict) -> dict: # person: it is a build instruction, not something to explain in a form. fields["outputs"] = ["HTML", "ics"] if collection == "post": - if form["categories"]: - fields["categories"] = form["categories"] if form["description"]: fields["description"] = form["description"] if form["image"]: @@ -181,17 +172,17 @@ def _cache_read(path: str, sha: str): def _cache_write(path: str, sha: str, fm: dict) -> None: get_db().execute( - """INSERT INTO content_cache (path, sha, title, date, categories, generated, + """INSERT INTO content_cache (path, sha, title, date, generated, event_date, event_time, event_location) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(path) DO UPDATE SET sha = excluded.sha, title = excluded.title, date = excluded.date, - categories = excluded.categories, generated = excluded.generated, + generated = excluded.generated, event_date = excluded.event_date, event_time = excluded.event_time, event_location = excluded.event_location, updated_at = datetime('now')""", (path, sha, str(fm.get("title", "")), str(fm.get("date", "")), - ", ".join(fm.get("categories") or []), 1 if fm.get("translated_from") else 0, + 1 if fm.get("translated_from") else 0, # Cached for the private calendar, which shows public events beside the # internal ones and would otherwise read every post's frontmatter on # every page view to find out when they are. @@ -223,7 +214,7 @@ def listing(collection: str) -> list[dict]: items.append({ "name": name, "path": path, "sha": sha, "title": row["title"] or name, - "date": row["date"], "categories": row["categories"], + "date": row["date"], "event_date": row["event_date"] or "", "event_time": row["event_time"] or "", "event_location": row["event_location"] or "", @@ -275,8 +266,6 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]: except ValueError: errors.append("La fecha debe tener el formato AAAA-MM-DD.") - categories = [c for c in request.form.getlist("categories") if c in CATEGORIES] - # A page's place in the menu. `parent` is another page's basename — the one # translate.py uses to pair siblings, so a parent chosen once holds in all # three languages — and the menu is built from these, not from a list in @@ -297,7 +286,7 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]: # When a post is an event, it has a date of its own. The post's `date` above # is when it was announced — often weeks earlier, and the thing Hugo sorts # the blog by — so the two cannot be the same field. - event = read_event_fields(request.form, categories, errors) + event = read_event_fields(request.form, errors) faq = clean_faq(request.form.get("faq", "")) image_alt = request.form.get("image_alt", "").strip()[:200] @@ -322,7 +311,7 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]: errors.append("El cuerpo no puede estar vacío.") fields = { - "title": title, "date": when, "categories": categories, + "title": title, "date": when, "description": request.form.get("description", "").strip(), "image": image, "manual_translation": request.form.get("manual_translation") == "on", @@ -368,27 +357,33 @@ def commit_picture(data: bytes, filename: str, author=None) -> str: return f"/uploads/{name}" -def read_event_fields(form, categories: list[str], errors: list[str]) -> dict: - """The three fields that come with the Evento category. +def read_event_fields(form, errors: list[str]) -> dict: + """The three fields that make a post an event. + + **The date is the marker.** There used to be an «Evento» category to tick + first, and ticking it without filling the date in was an error the form had + to refuse. With the categories gone there is nothing to tick: a post that + carries a date is an event, which also means there is no way left to say + "this is an event" and then not say when. Shared by the editor and by a member's proposal, so a post written by a moderator and one approved from the queue carry the same frontmatter. The - date is required and the other two are not: an event with no time is an - all-day event, and one with no place is a mistake somebody can fix later - rather than a reason to refuse the whole post. + other two fields stay optional: an event with no time is an all-day event, + and one with no place is a mistake somebody can fix later rather than a + reason to refuse the whole post. - Returns empty strings when the category is absent, so an ordinary article - never carries empty event lines in its frontmatter. + Returns empty strings when no date was given, so an ordinary article never + carries empty event lines in its frontmatter. """ - if EVENT_CATEGORY not in categories: + raw = form.get("event_date", "").strip() + if not raw: return {"event_date": "", "event_time": "", "event_location": ""} - raw = form.get("event_date", "").strip() try: event_date = datetime.strptime(raw, "%Y-%m-%d").date().isoformat() except ValueError: event_date = "" - errors.append("Un evento necesita fecha, con el formato AAAA-MM-DD.") + errors.append("La fecha del evento debe tener el formato AAAA-MM-DD.") event_time = form.get("event_time", "").strip() if event_time and not EVENT_TIME.match(event_time): @@ -505,7 +500,7 @@ def new(collection: str): meta = _collection_or_404(collection) if request.method == "GET": return render_template("content_form.html", collection=collection, meta=meta, - categories=CATEGORIES, item=None, fields=None, + item=None, fields=None, body="", today=date_type.today().isoformat(), parents=possible_parents(collection)) @@ -548,7 +543,6 @@ def edit(collection: str, name: str): fields = { "title": fm.get("title", ""), "date": fm.get("date"), - "categories": fm.get("categories") or [], "description": fm.get("description", ""), "image": fm.get("image", ""), "manual_translation": bool(fm.get("manual_translation")), @@ -567,7 +561,7 @@ def edit(collection: str, name: str): "event_location": fm.get("event_location", ""), } return render_template("content_form.html", collection=collection, meta=meta, - categories=CATEGORIES, item={"name": name, "sha": sha}, + item={"name": name, "sha": sha}, fields=fields, body=body, today=date_type.today().isoformat(), parents=possible_parents(collection, name)) @@ -628,7 +622,7 @@ def preview(collection: str): sha = request.form.get("sha", "") item = {"name": request.form.get("name", ""), "sha": sha} if sha else None return render_template("content_form.html", collection=collection, meta=meta, - categories=CATEGORIES, item=item, fields=fields, body=body, + item=item, fields=fields, body=body, today=date_type.today().isoformat(), parents=possible_parents(collection, item["name"] if item else ""), @@ -686,7 +680,7 @@ def _back_to_form(collection, meta, fields, body, errors, item): for message in errors: flash(message, "error") return render_template("content_form.html", collection=collection, meta=meta, - categories=CATEGORIES, item=item, fields=fields, body=body, + item=item, fields=fields, body=body, today=date_type.today().isoformat(), parents=possible_parents(collection, item["name"] if item else "")), 400 diff --git a/apps/board/events.py b/apps/board/events.py index 067bcde..e270a0d 100644 --- a/apps/board/events.py +++ b/apps/board/events.py @@ -3,9 +3,9 @@ What the association is doing and when, for the people inside: a meeting, a rehearsal, a visit somewhere. Admins write them, every member reads them, and nothing here is ever published — no Open Graph, no sitemap, nothing written to -/var/www. That is the whole difference between this and a post in the Evento -category, and it is why the two live in different places rather than behind a -flag on one. +/var/www. That is the whole difference between this and a public post carrying +an event date, and it is why the two live in different places rather than behind +a flag on one. **The public events appear here too**, marked as public and linking to the site, because a member should have one place to look rather than two. They come from diff --git a/apps/board/migrations.py b/apps/board/migrations.py index 29447a4..c2c8c03 100644 --- a/apps/board/migrations.py +++ b/apps/board/migrations.py @@ -232,6 +232,23 @@ def _rooms_for_a_date_of_its_own(db: sqlite3.Connection) -> None: db.execute(f"ALTER TABLE {table} ADD COLUMN {column} TEXT") +def _no_more_categories(db: sqlite3.Connection) -> None: + """Take the category column off the two tables that carried one. + + `DROP COLUMN` rather than a rebuild: SQLite has had it since 3.35 and + neither column is in a CHECK, an index or a foreign key, which are the three + things that make it refuse. The rebuilds in steps 1 and 4 exist because a + CHECK cannot be altered any other way — this needs none of that. + + Dropping rather than leaving a column nobody writes to: a dead column is a + question for whoever reads this schema next, and the answer ("we used to + have categories") is not in the file. + """ + for table in ("content_cache", "submissions"): + if "categories" in _columns(db, table): + db.execute(f"ALTER TABLE {table} DROP COLUMN categories") + + # (number, description, function). The number is the value written to # user_version once the step succeeds. STEPS = [ @@ -240,6 +257,7 @@ STEPS = [ (3, "members can have a public page", _members_get_a_public_page), (4, "members can be moderators", _members_can_moderate), (5, "events carry a date of their own", _rooms_for_a_date_of_its_own), + (6, "there are no categories any more", _no_more_categories), ] diff --git a/apps/board/profiles.py b/apps/board/profiles.py index 90c6189..8af246e 100644 --- a/apps/board/profiles.py +++ b/apps/board/profiles.py @@ -42,6 +42,10 @@ LINKS_MAX = 8 # collision harmless rather than dangerous — Hugo wins and the profile is # simply unreachable — so this exists to stop somebody discovering months later # that their page has never loaded for anybody. +# +# `categories` and `tags` stay on the list although the taxonomies are gone: the +# site served those paths for a year, and a URL somebody may still have in a +# bookmark or a search index should not quietly become a member's profile. RESERVED = { "de", "pt-br", "es", "en", # language trees "page", "post", "posts", "categories", "tags", "category", "tag", diff --git a/apps/board/schema.sql b/apps/board/schema.sql index ef498e2..9ad1ca4 100644 --- a/apps/board/schema.sql +++ b/apps/board/schema.sql @@ -189,7 +189,6 @@ CREATE TABLE IF NOT EXISTS content_cache ( sha TEXT NOT NULL, title TEXT NOT NULL DEFAULT '', date TEXT NOT NULL DEFAULT '', - categories TEXT NOT NULL DEFAULT '', -- Files carrying `translated_from` are the pipeline's output, not anyone's -- draft. Recorded here so the listing can skip them without re-reading -- every file to find out what it already knew. @@ -245,10 +244,9 @@ CREATE TABLE IF NOT EXISTS submissions ( title TEXT NOT NULL, body_md TEXT NOT NULL, description TEXT NOT NULL DEFAULT '', - categories TEXT NOT NULL DEFAULT '', -- comma-separated, as content_cache - -- Set only when the proposal carries the Evento category. The event's own - -- date, which is not the day it is published: a member announcing a concert - -- three weeks out is the normal case. + -- The event's own date, which is also what makes this proposal an event at + -- all. It is not the day it is published: a member announcing a concert three + -- weeks out is the normal case. event_date TEXT, event_time TEXT, event_location TEXT, @@ -304,7 +302,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS reactions_one_per_comment -- Events the association puts on for its members: a meeting, a rehearsal, a -- visit somewhere. Written by admins, read by every member, and never published -- — nothing here reaches /var/www, the sitemap or a share card, which is the --- difference between this table and a post with the Evento category. +-- difference between this table and a public post carrying an event date. -- -- `starts_on` and `starts_at` are kept apart rather than as one timestamp -- because an event with no time is an ordinary thing ("the whole Saturday") and diff --git a/apps/board/static/board.css b/apps/board/static/board.css index 353941c..5ad5986 100644 --- a/apps/board/static/board.css +++ b/apps/board/static/board.css @@ -68,6 +68,10 @@ button, input, select, textarea { font: inherit; } align-items: center; justify-content: space-between; gap: 1rem; + /* A long display name beside a logo has nowhere to go on a phone otherwise, + and `space-between` pushes the brand off the left edge rather than + wrapping. */ + flex-wrap: wrap; } .site-bar__brand { text-decoration: none; } @@ -84,7 +88,15 @@ button, input, select, textarea { font: inherit; } padding: 0.6rem 16px; list-style: none; display: flex; - gap: 1.5rem; + gap: 0.5rem 1.5rem; + /* Six sections and their badges do not fit across a phone. Without this the + row overflowed and took the whole page sideways with it — a members area + you had to scroll right to read. + Wrapping rather than a strip you swipe: two lines show all six, and a + horizontal scroll would have left Calendario and Gestión off the right + edge with nothing to say they were there. On a laptop it is one line + either way. */ + flex-wrap: wrap; } .page-nav a { color: var(--muted); text-decoration: none; } .page-nav a:hover { color: var(--brand); } diff --git a/apps/board/submissions.py b/apps/board/submissions.py index e575549..e0ffda5 100644 --- a/apps/board/submissions.py +++ b/apps/board/submissions.py @@ -92,17 +92,14 @@ def _read_proposal() -> tuple[dict, list[str]]: """The same fields the editor asks for, minus the ones only a publisher decides: the date is the day it is approved, and `manual_translation` is a pipeline switch, not something to explain to a member.""" - categories = [c for c in request.form.getlist("categories") - if c in content.CATEGORIES] errors = [] fields = { "title": request.form.get("title", "").strip()[:TITLE_MAX], "body": request.form.get("body", "").strip()[:BODY_MAX], "description": request.form.get("description", "").strip()[:300], - "categories": categories, # The same three fields the editor asks for, read by the same function: # a member's event and a moderator's have to produce the same post. - **content.read_event_fields(request.form, categories, errors), + **content.read_event_fields(request.form, errors), } if not fields["title"]: errors.append("El título no puede estar vacío.") @@ -154,8 +151,7 @@ def propose(): return redirect(url_for("content.new", collection="post")) if request.method == "GET": - return render_template("submission_form.html", item=None, fields=None, - categories=content.CATEGORIES) + return render_template("submission_form.html", item=None, fields=None) fields, errors = _read_proposal() waiting = get_db().execute( @@ -179,11 +175,11 @@ def propose(): photo_name = _store_picture(staged) get_db().execute( """INSERT INTO submissions - (author_id, title, body_md, description, categories, photo_name, + (author_id, title, body_md, description, photo_name, event_date, event_time, event_location) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""", + VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", (g.member["id"], fields["title"], fields["body"], fields["description"], - ", ".join(fields["categories"]), photo_name, + photo_name, fields["event_date"], fields["event_time"], fields["event_location"]), ) flash("Enviado. Un moderador lo leerá antes de publicarlo.", "ok") @@ -217,12 +213,10 @@ def edit(submission_id: int): return redirect(url_for("submissions.index")) if request.method == "GET": - return render_template("submission_form.html", item=row, categories=content.CATEGORIES, + return render_template("submission_form.html", item=row, fields={ "title": row["title"], "body": row["body_md"], "description": row["description"], - "categories": [c.strip() for c in - (row["categories"] or "").split(",") if c.strip()], "event_date": row["event_date"] or "", "event_time": row["event_time"] or "", "event_location": row["event_location"] or "", @@ -246,14 +240,14 @@ def edit(submission_id: int): get_db().execute( """UPDATE submissions - SET title = ?, body_md = ?, description = ?, categories = ?, + SET title = ?, body_md = ?, description = ?, photo_name = ?, event_date = ?, event_time = ?, event_location = ?, state = 'pending', note = NULL, reviewed_by = NULL, reviewed_at = NULL, updated_at = datetime('now') WHERE id = ?""", (fields["title"], fields["body"], fields["description"], - ", ".join(fields["categories"]), photo_name, fields["event_date"], + photo_name, fields["event_date"], fields["event_time"], fields["event_location"], submission_id), ) # Back to pending on every edit, including one made after a rejection: a @@ -320,7 +314,6 @@ def approve(submission_id: int): # this and the URL carries it, so a proposal that waited a week should # not arrive dated a week ago. "date": date_type.today(), - "categories": [c.strip() for c in (row["categories"] or "").split(",") if c.strip()], "description": row["description"], "image": "", "manual_translation": False, @@ -419,5 +412,4 @@ def _store_picture(staged: list[dict]) -> str | None: def _back_to_form(item, fields, errors): for message in errors: flash(message, "error") - return render_template("submission_form.html", item=item, fields=fields, - categories=content.CATEGORIES), 400 + return render_template("submission_form.html", item=item, fields=fields), 400 diff --git a/apps/board/templates/content_form.html b/apps/board/templates/content_form.html index edb306e..f62d82d 100644 --- a/apps/board/templates/content_form.html +++ b/apps/board/templates/content_form.html @@ -66,26 +66,15 @@ {% endif %} {% if collection == 'post' %} -
- Categorías - {% for category in categories %} - - {% endfor %} -
- - {# An event's own date, which is not the day the post goes up. Shown whenever - a post can be written: ticking Evento above is what makes these required, - checked on the server rather than hidden and shown with a script. #} + {# An event's own date, which is not the day the post goes up. The date is + also what makes this post an event: there is nothing to tick first, so + there is no way to say "this is an event" and then not say when. #}
Si es un evento

- Marca Evento arriba y rellena al menos la fecha. El - evento aparecerá en la agenda del sitio y se podrá añadir al - calendario del móvil. + Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el + día y el lugar destacados, y se podrá añadir al calendario del móvil. + Déjala vacía y es un artículo normal.

diff --git a/apps/board/templates/content_list.html b/apps/board/templates/content_list.html index eaa9ca6..644c33b 100644 --- a/apps/board/templates/content_list.html +++ b/apps/board/templates/content_list.html @@ -21,7 +21,7 @@ {% else %} - {% if meta.dated %}{% endif %} + {% if meta.dated %}{% endif %}{% if meta.dated %}{% endif %} {% for item in items %} @@ -31,7 +31,10 @@
{{ item.name }}
{% if meta.dated %}{% endif %} - + {# The column that used to hold the categories. An event date is the + one thing left that changes what a post is, and it is what a + moderator scanning this list is looking for. #} + {% if meta.dated %}{% endif %} {# The flex row goes INSIDE the cell, never on it. `.actions` is display:flex, and a
TítuloFechaCategorías
TítuloFechaEvento
{{ item.date }}{{ item.categories }}{{ item.event_date }} told to be a flex container stops being a table cell: it leaves the row's layout and draws its bottom border diff --git a/apps/board/templates/event.html b/apps/board/templates/event.html index f40a705..7c025ff 100644 --- a/apps/board/templates/event.html +++ b/apps/board/templates/event.html @@ -36,6 +36,6 @@

Este evento sólo se ve desde el área de miembros. Para anunciar algo a todo el mundo, usa Publicaciones - con la categoría «Evento». + poniéndole una fecha de evento.

{% endblock %} diff --git a/apps/board/templates/submission.html b/apps/board/templates/submission.html index 6e88045..cb52f37 100644 --- a/apps/board/templates/submission.html +++ b/apps/board/templates/submission.html @@ -12,7 +12,7 @@
{{ labels[item.state] }} {{ person(item.author, item.author_login) }} · - {% if item.categories %} · {{ item.categories }}{% endif %} + {% if item.event_date %} · Evento el {{ item.event_date }}{% endif %}
{% if item.description %}

{{ item.description }}

{% endif %} {% if item.photo_name %} diff --git a/apps/board/templates/submission_form.html b/apps/board/templates/submission_form.html index 72928b2..3aa6d82 100644 --- a/apps/board/templates/submission_form.html +++ b/apps/board/templates/submission_form.html @@ -24,26 +24,14 @@ value="{{ fields.description if fields else '' }}">

Una o dos líneas: es lo que se ve en los listados.

-
- Categorías - {% for category in categories %} - - {% endfor %} -
- - {# An event's own date, which is not the day the post goes up. Shown whenever - a post can be written: ticking Evento above is what makes these required, - checked on the server rather than hidden and shown with a script. #} + {# An event's own date, which is not the day the post goes up. The date is + also what makes this an event: there is nothing to tick first, so there is + no way to say "this is an event" and then not say when. #}
Si es un evento

- Marca Evento arriba y rellena al menos la fecha. El - evento aparecerá en la agenda del sitio y se podrá añadir al - calendario del móvil. + Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el + día y el lugar destacados. Déjala vacía y es un artículo normal.

diff --git a/apps/board/tests/test_content.py b/apps/board/tests/test_content.py index bd112c7..a1b43da 100644 --- a/apps/board/tests/test_content.py +++ b/apps/board/tests/test_content.py @@ -66,12 +66,12 @@ def test_accents_are_folded_not_dropped(): def test_the_frontmatter_marks_an_authored_source(repo, editor, post): - publish(post, categories="Gastronomía", description="Un resumen.") + publish(post, description="Un resumen.") path, = repo.files fm, body = translate.split_frontmatter(repo.files[path].decode()) assert fm["lang"] == "es" assert fm["manual_translation"] is False - assert fm["categories"] == ["Gastronomía"] + assert "categories" not in fm # the taxonomy is gone, not emptied assert "translated_from" not in fm # what makes it a source, not output assert not translate.is_generated(fm) assert body.strip() == "Texto del artículo." @@ -561,7 +561,7 @@ def test_an_event_carries_its_own_date_and_an_ics(repo, editor, post): import yaml post("/comunidad/contenido/post/nuevo", {"title": "Feria de otoño", "body": "Ven.", "date": "2026-10-03", - "categories": ["Evento", "Comunidad"], "event_date": "2026-10-24", + "event_date": "2026-10-24", "event_time": "18:30", "event_location": "Plaza de Ottakring"}) path, = repo.files @@ -574,21 +574,23 @@ def test_an_event_carries_its_own_date_and_an_ics(repo, editor, post): assert front["outputs"] == ["HTML", "ics"] -def test_the_evento_category_without_a_date_is_refused(repo, editor, post): +def test_a_post_with_no_event_date_is_simply_an_article(repo, editor, post): + """There is nothing to tick any more, so there is no "said it was an event + and did not say when" to refuse. The date is the whole declaration.""" + import yaml response = post("/comunidad/contenido/post/nuevo", - {"title": "Algún día", "body": "Texto.", "date": "2026-10-03", - "categories": ["Evento"]}) + {"title": "Algún día", "body": "Texto.", "date": "2026-10-03"}) - assert response.status_code == 400 - assert "necesita fecha" in response.get_data(as_text=True) - assert repo.files == {} + assert response.status_code == 302 + path, = repo.files + front = yaml.safe_load(repo.files[path].decode().split("---")[1]) + assert "event_date" not in front def test_a_nonsense_hour_is_refused(repo, editor, post): response = post("/comunidad/contenido/post/nuevo", {"title": "Feria", "body": "Texto.", "date": "2026-10-03", - "categories": ["Evento"], "event_date": "2026-10-24", - "event_time": "25:99"}) + "event_date": "2026-10-24", "event_time": "25:99"}) assert response.status_code == 400 assert repo.files == {} @@ -599,7 +601,7 @@ def test_an_ordinary_post_carries_no_event_lines(repo, editor, post): import yaml post("/comunidad/contenido/post/nuevo", {"title": "Un artículo", "body": "Texto.", "date": "2026-10-03", - "categories": ["Cultura"], "event_date": "2026-10-24"}) + "event_date": ""}) path, = repo.files front = yaml.safe_load(repo.files[path].decode().split("---")[1]) @@ -612,7 +614,7 @@ def test_an_event_keeps_its_date_when_edited(repo, editor, post, client): repo.files["content/post/2026-10-03-feria.es.md"] = ( "---\ntitle: Feria\ndate: 2026-10-03\nlang: es\nmanual_translation: false\n" "event_date: '2026-10-24'\nevent_time: '18:30'\n" - "event_location: La plaza\ncategories:\n- Evento\n---\n\nVen.\n").encode("utf-8") + "event_location: La plaza\n---\n\nVen.\n").encode("utf-8") body = client.get("/comunidad/contenido/post/editar/2026-10-03-feria.es.md").get_data(as_text=True) assert 'value="2026-10-24"' in body @@ -620,7 +622,7 @@ def test_an_event_keeps_its_date_when_edited(repo, editor, post, client): post("/comunidad/contenido/post/editar/2026-10-03-feria.es.md", {"title": "Feria", "body": "Ven pronto.", "date": "2026-10-03", - "categories": ["Evento"], "event_date": "2026-10-24", + "event_date": "2026-10-24", "event_time": "18:30", "event_location": "La plaza", "sha": repo._sha(repo.files["content/post/2026-10-03-feria.es.md"])}) diff --git a/apps/board/tests/test_migrations.py b/apps/board/tests/test_migrations.py index ad2f22a..0bf5d20 100644 --- a/apps/board/tests/test_migrations.py +++ b/apps/board/tests/test_migrations.py @@ -319,3 +319,43 @@ def test_the_app_starts_against_a_database_from_before_all_this(tmp_path): create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador", "UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True}) db.close() + + +def test_step_six_drops_the_category_columns_and_keeps_the_rows(tmp_path): + """The categories are gone; the two columns that held them go with them. + + Built on the current schema rather than an old one, because the point here + is not "does an old database survive" — step 5's test covers that — but + that a database which *has* the column loses it without losing anything + around it. A dropped column takes its data and nothing else, and a row + written before the drop still reads afterwards. + """ + from apps.board.app import create_app + from apps.board.db import connect + + path = str(tmp_path / "board.db") + create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador", + "UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True}) + + db = connect(path) + # Put the column back and fill it, as a server that has been running since + # before this phase would have it. + db.execute("ALTER TABLE content_cache ADD COLUMN categories TEXT NOT NULL DEFAULT ''") + db.execute("""INSERT INTO content_cache (path, sha, title, date, categories, event_date) + VALUES ('content/post/2026-10-24-feria.es.md', 'abc', 'Feria', + '2026-10-24', 'Evento, Comunidad', '2026-11-07')""") + db.execute("PRAGMA user_version = 5") + db.commit() + db.close() + + create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador", + "UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True}) + + db = connect(path) + columns = {row[1] for row in db.execute("PRAGMA table_info(content_cache)")} + assert "categories" not in columns + row = db.execute("SELECT title, event_date FROM content_cache").fetchone() + assert (row["title"], row["event_date"]) == ("Feria", "2026-11-07") + assert db.execute("PRAGMA user_version").fetchone()[0] == max( + number for number, _, _ in migrations.STEPS) + db.close() diff --git a/apps/board/tests/test_submissions.py b/apps/board/tests/test_submissions.py index 894e086..f24a8fb 100644 --- a/apps/board/tests/test_submissions.py +++ b/apps/board/tests/test_submissions.py @@ -73,11 +73,10 @@ def test_a_proposal_is_a_row_and_not_a_commit(repo, db, post, maria, sign_in): """The whole point of the table. If this ever commits, the post is on vienalatina.com before anybody has read it.""" sign_in(maria) - propose(post, description="Una feria", categories=["Comunidad"]) + propose(post, description="Una feria") row = only_submission(db) - assert (row["state"], row["title"], row["categories"]) == ( - "pending", "Feria en Ottakring", "Comunidad") + assert (row["state"], row["title"]) == ("pending", "Feria en Ottakring") assert repo.files == {} assert repo.commits == [] @@ -189,7 +188,7 @@ def test_approving_commits_once_under_the_author_is_name( """Attribution is the reason `write_file` takes an author at all. A post approved by Luisa but written by María has to say María in git.""" sign_in(maria) - propose(post, categories=["Comunidad"]) + propose(post) submission_id = only_submission(db)["id"] sign_in(luisa) @@ -205,11 +204,11 @@ def test_approving_commits_once_under_the_author_is_name( def test_the_approved_file_is_what_the_pipeline_expects(repo, db, post, maria, luisa, sign_in): - """The same contract the editor's own tests hold it to: Spanish source, no - `translated_from`, categories as a list.""" + """The same contract the editor's own tests hold it to: a Spanish source + with no `translated_from`.""" import yaml sign_in(maria) - propose(post, categories=["Comunidad", "Cultura"], description="Una feria") + propose(post, description="Una feria") submission_id = only_submission(db)["id"] sign_in(luisa) @@ -220,7 +219,7 @@ def test_the_approved_file_is_what_the_pipeline_expects(repo, db, post, maria, front = yaml.safe_load(text.split("---")[1]) assert front["lang"] == "es" assert front["manual_translation"] is False - assert front["categories"] == ["Comunidad", "Cultura"] + assert "categories" not in front assert front["description"] == "Una feria" assert "translated_from" not in front assert "empanadas" in text @@ -477,7 +476,7 @@ def test_a_member_can_propose_an_event_and_it_keeps_its_date( site is the one the member described, dated when it happens.""" import yaml sign_in(maria) - propose(post, categories=["Evento"], event_date="2026-11-07", + propose(post, event_date="2026-11-07", event_time="20:00", event_location="Sala Ottakring") submission_id = only_submission(db)["id"] @@ -492,10 +491,13 @@ def test_a_member_can_propose_an_event_and_it_keeps_its_date( assert front["author"] == "Maria" -def test_an_event_proposal_without_a_date_is_refused(db, post, maria, sign_in): +def test_a_proposal_with_a_nonsense_event_date_is_refused(db, post, maria, sign_in): + """A proposal with no date at all is just an article, so there is nothing + left to refuse there — the date is the declaration. A date that is not a + date still is.""" sign_in(maria) - response = propose(post, categories=["Evento"]) + response = propose(post, event_date="el martes") assert response.status_code == 400 assert db.execute("SELECT COUNT(*) AS n FROM submissions").fetchone()["n"] == 0 diff --git a/apps/board/tests/test_templates.py b/apps/board/tests/test_templates.py index a5ef914..e7536e9 100644 --- a/apps/board/tests/test_templates.py +++ b/apps/board/tests/test_templates.py @@ -207,3 +207,48 @@ def test_the_form_rule_is_an_exclusion_and_not_a_list_of_accepted_types(): ) for typed_in in ("password", "number", "email", "date", "text", "search", "url"): assert typed_in not in excluded, f"{typed_in} is a box somebody types in" + + +# --- the theme's own chrome ----------------------------------------------- +# +# These two read the Hugo theme rather than the members area, which no other +# test here does. They are here because the bug they guard against is this +# suite's recurring shape — CSS that expects markup nobody wrote — and because +# pytest is the only thing in this repository that runs on every commit. + +THEME = Path(__file__).resolve().parents[3] / "themes" / "vienalatina" + + +def test_the_collapsed_menu_has_something_that_can_open_it(): + """The one that shipped: `main.css` hid `.site-bar__pages` below 768px and + showed it again on a toggle, the hamburger's own styles were ported with + it, and `header.html` never got the button. For three phases the public + site had no navigation at all on a phone — every rule correct, every + selector pointing at an element that did not exist. + + So: if the stylesheet hides the menu behind a state, the header has to carry + that state and the control that flips it. + """ + css = (THEME / "assets" / "css" / "main.css").read_text(encoding="utf-8") + header = (THEME / "layouts" / "partials" / "header.html").read_text(encoding="utf-8") + + assert ".site-menu__state:checked ~ .site-bar__pages" in css, ( + "main.css no longer opens the mobile menu from the checkbox. If the " + "mechanism changed, change this test with it — but check first that the " + "menu still opens on a phone." + ) + for needed in ('id="site-menu"', 'class="site-menu__state"', 'for="site-menu"'): + assert needed in header, ( + f"header.html has no {needed}. The CSS hides the menu on a phone and " + "only shows it again on that checkbox, so without it the site has no " + "navigation below 768px." + ) + + +def test_the_way_into_the_members_area_is_in_the_bar_itself(): + """Not in the menu. It was a menu entry, which on a phone put it inside a + menu that did not open — and even on a desktop made the one link that is not + content look like one of the pages.""" + header = (THEME / "layouts" / "partials" / "header.html").read_text(encoding="utf-8") + bar = header.split(' diff --git a/themes/vienalatina/layouts/partials/seo-head.html b/themes/vienalatina/layouts/partials/seo-head.html index b3ecfe2..251ddff 100644 --- a/themes/vienalatina/layouts/partials/seo-head.html +++ b/themes/vienalatina/layouts/partials/seo-head.html @@ -57,7 +57,6 @@ {{ with .Params.author }}{{ end }} -{{ range first 1 (.GetTerms "categories") }}{{ end }} diff --git a/themes/vienalatina/layouts/partials/t.html b/themes/vienalatina/layouts/partials/t.html index e00b7a9..a920055 100644 --- a/themes/vienalatina/layouts/partials/t.html +++ b/themes/vienalatina/layouts/partials/t.html @@ -18,6 +18,8 @@ "next" (dict "es" "Mes siguiente" "de" "Nächster Monat" "pt-br" "Próximo mês") "noevents" (dict "es" "No hay nada en este mes." "de" "In diesem Monat ist nichts geplant." "pt-br" "Nada marcado neste mês.") "allevents" (dict "es" "Todos los eventos" "de" "Alle Termine" "pt-br" "Todos os eventos") + "community" (dict "es" "Comunidad" "de" "Community" "pt-br" "Comunidade") + "menu" (dict "es" "Menú" "de" "Menü" "pt-br" "Menu") -}} {{- $entry := index $words .key -}} {{- if $entry -}}