From 566c5787706c8940d22aae965d38b4d5b8d1bb65 Mon Sep 17 00:00:00 2001 From: Deeman Date: Tue, 24 Feb 2026 01:13:22 +0100 Subject: [PATCH] fix: correct broken status display and source column in articles list - Compute display_status (live/scheduled/draft) in SQL instead of broken Jinja string comparison against undefined `now` variable - Replace template_data_id (dropped in migration 0018) with template_slug Subtask 1/8 of CMS admin improvement. Co-Authored-By: Claude Opus 4.6 --- web/src/padelnomics/admin/routes.py | 7 ++++++- .../padelnomics/admin/templates/admin/articles.html | 12 +++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/web/src/padelnomics/admin/routes.py b/web/src/padelnomics/admin/routes.py index 93652c5..6613cae 100644 --- a/web/src/padelnomics/admin/routes.py +++ b/web/src/padelnomics/admin/routes.py @@ -1586,7 +1586,12 @@ async def scenario_pdf(scenario_id: int): async def articles(): """List all articles.""" article_list = await fetch_all( - "SELECT * FROM articles ORDER BY created_at DESC" + """SELECT *, + CASE WHEN status = 'published' AND published_at > datetime('now') + THEN 'scheduled' + WHEN status = 'published' THEN 'live' + ELSE status END AS display_status + FROM articles ORDER BY created_at DESC""" ) return await render_template("admin/articles.html", articles=article_list) diff --git a/web/src/padelnomics/admin/templates/admin/articles.html b/web/src/padelnomics/admin/templates/admin/articles.html index 663dc81..81392c6 100644 --- a/web/src/padelnomics/admin/templates/admin/articles.html +++ b/web/src/padelnomics/admin/templates/admin/articles.html @@ -38,18 +38,16 @@ {{ a.title }} {{ a.url_path }} - {% if a.status == 'published' %} - {% if a.published_at and a.published_at > now.isoformat() %} - Scheduled - {% else %} + {% if a.display_status == 'live' %} Published - {% endif %} + {% elif a.display_status == 'scheduled' %} + Scheduled {% else %} - Draft + Draft {% endif %} {{ a.published_at[:10] if a.published_at else '-' }} - {% if a.template_data_id %}Generated{% else %}Manual{% endif %} + {% if a.template_slug %}{{ a.template_slug }}{% else %}Manual{% endif %}