', content, flags=re.DOTALL)
+ # A feed that gave no publish date falls back to when it was fetched
+ # (the same fallback the stream's sort order uses), so the row still
+ # carries a time and groups under a real date, not "Undated".
+ undated_row = re.search(rf'
', content, flags=re.DOTALL)
assert undated_row is not None
- assert 'data-published-utc=""' in undated_row.group(0)
+ row_html = undated_row.group(0)
+ assert f'data-published-utc="{undated.fetched_at.isoformat()}"' in row_html
+ assert 'class="article-time"' in row_html
+ assert "Undated" not in content
@pytest.mark.django_db
@@ -473,3 +479,27 @@ def test_article_detail_back_link_keeps_the_stream_scope(client, alice):
assert f"filter=all&feed={feed.pk}" in detail
assert "Back to stream" in detail
assert article.title in detail
+
+
+@pytest.mark.django_db
+def test_article_with_no_publish_date_shows_when_it_was_fetched(client, alice):
+ """A feed that gives no date is treated as published when we fetched
+ it — in the list row, its group header, and the open article's header
+ — without storing an invented value on the article itself."""
+ feed = Feed.objects.create(feed_url="https://example.com/feed.xml")
+ Subscription.objects.create(user=alice, feed=feed)
+ article = Article.objects.create(feed=feed, guid="g1", title="No publish date")
+ assert article.published_at is None
+
+ client.login(username="alice", password="pw-alice-123")
+ iso = article.fetched_at.isoformat()
+
+ stream = client.get(reverse("reader:stream"), {"filter": "all"}).content.decode()
+ assert f'datetime="{iso}"' in stream
+ assert "Received today" in stream
+
+ detail = client.get(reverse("reader:article_detail", args=[article.pk])).content.decode()
+ assert f'datetime="{iso}"' in detail
+
+ article.refresh_from_db()
+ assert article.published_at is None
diff --git a/apps/reader/views.py b/apps/reader/views.py
index 46fa3af..e66a83a 100644
--- a/apps/reader/views.py
+++ b/apps/reader/views.py
@@ -113,7 +113,8 @@ def _group_by_date(articles):
today = timezone.localdate()
def day_of(article):
- return timezone.localtime(article.published_at).date() if article.published_at else None
+ when = article.published_at or article.fetched_at
+ return timezone.localtime(when).date() if when else None
return [
{"label": _date_label(day, today), "articles": list(items)}
diff --git a/templates/reader/_article_content.html b/templates/reader/_article_content.html
index bbd84db..239b0dc 100644
--- a/templates/reader/_article_content.html
+++ b/templates/reader/_article_content.html
@@ -3,9 +3,8 @@
{% if article.feed.favicon_url %}{% endif %}
{{ article.feed.title }}
- {% if article.published_at %}
- ·
- {% endif %}
+ {# fetched_at stands in when the feed gave no publish date #}
+ ·
{% if article.author %} · {{ article.author }}{% endif %}
{% if article.link %} · Original ↗{% endif %}
{% include "reader/_article_actions.html" %}
{% if article.feed.favicon_url %}
@@ -8,9 +8,8 @@
{{ article.feed.title|default:article.feed.feed_url }}{{ article.title|default:"(untitled)" }}
- {% if article.published_at %}
-
- {% endif %}
+ {# fetched_at stands in when a feed gives no publish date — same fallback the stream's sort order uses #}
+