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 <noreply@anthropic.com>
This commit is contained in:
@@ -1586,7 +1586,12 @@ async def scenario_pdf(scenario_id: int):
|
|||||||
async def articles():
|
async def articles():
|
||||||
"""List all articles."""
|
"""List all articles."""
|
||||||
article_list = await fetch_all(
|
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)
|
return await render_template("admin/articles.html", articles=article_list)
|
||||||
|
|
||||||
|
|||||||
@@ -38,18 +38,16 @@
|
|||||||
<td>{{ a.title }}</td>
|
<td>{{ a.title }}</td>
|
||||||
<td class="mono text-sm">{{ a.url_path }}</td>
|
<td class="mono text-sm">{{ a.url_path }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if a.status == 'published' %}
|
{% if a.display_status == 'live' %}
|
||||||
{% if a.published_at and a.published_at > now.isoformat() %}
|
|
||||||
<span class="badge-warning">Scheduled</span>
|
|
||||||
{% else %}
|
|
||||||
<span class="badge-success">Published</span>
|
<span class="badge-success">Published</span>
|
||||||
{% endif %}
|
{% elif a.display_status == 'scheduled' %}
|
||||||
|
<span class="badge-warning">Scheduled</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge">Draft</span>
|
<span class="badge">Draft</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="mono text-sm">{{ a.published_at[:10] if a.published_at else '-' }}</td>
|
<td class="mono text-sm">{{ a.published_at[:10] if a.published_at else '-' }}</td>
|
||||||
<td class="text-sm">{% if a.template_data_id %}Generated{% else %}Manual{% endif %}</td>
|
<td class="text-sm">{% if a.template_slug %}{{ a.template_slug }}{% else %}Manual{% endif %}</td>
|
||||||
<td class="text-right" style="white-space: nowrap;">
|
<td class="text-right" style="white-space: nowrap;">
|
||||||
<form method="post" action="{{ url_for('admin.article_publish', article_id=a.id) }}" class="m-0" style="display: inline;">
|
<form method="post" action="{{ url_for('admin.article_publish', article_id=a.id) }}" class="m-0" style="display: inline;">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
|
|||||||
Reference in New Issue
Block a user