From 40bee9af48afb9150b8d13790d2f409bb351471a Mon Sep 17 00:00:00 2001 From: Bernard Siebens Date: Fri, 21 Aug 2026 16:09:15 +0200 Subject: [PATCH] Show a News empty state on Home instead of hiding the card Previously the whole "Club news" card just vanished when there was nothing to show, dropping the "All news" link along with it. Now it always renders -- either the real teaser or a "No news yet" card, still linking through to mobile:news_list either way. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01ECGMEwrc2k4D8VQuwjstj9 --- mobile/templates/mobile/home.html | 22 +++++++++++++--------- mobile/tests.py | 9 +++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/mobile/templates/mobile/home.html b/mobile/templates/mobile/home.html index a24ccee..a96537e 100644 --- a/mobile/templates/mobile/home.html +++ b/mobile/templates/mobile/home.html @@ -126,12 +126,12 @@ {% endif %} - {% if news_items %} -
-
- {% trans "Club news" %} - {% trans "All news" %} -
+
+
+ {% trans "Club news" %} + {% trans "All news" %} +
+ {% if news_items %} {% with lead=news_items.0 %}
{% trans "News photo" %}
@@ -156,10 +156,14 @@ {% endfor %}
{% endif %} -
- {% endif %} + {% else %} +
+

{% trans "No news yet." %}

+
+ {% endif %} + - {% if not hero_attendance and not needs_answer and not dues_rows and not news_items %} + {% if not hero_attendance and not needs_answer and not dues_rows %}

{% trans "Nothing to show right now." %}

diff --git a/mobile/tests.py b/mobile/tests.py index ab8ad5f..bd076e0 100644 --- a/mobile/tests.py +++ b/mobile/tests.py @@ -326,6 +326,15 @@ class HomeViewTests(TestCase): self.assertEqual(list(response.context["news_items"]), []) + def test_news_card_shows_an_empty_state_with_a_link_to_all_news_when_there_is_none(self): + self.client.force_login(self.user) + + response = self._get("home") + + self.assertEqual(list(response.context["news_items"]), []) + self.assertContains(response, "No news yet.") + self.assertContains(response, 'href="/app/news/"') + def test_empty_account_gets_a_graceful_empty_state(self): bare_user = User.objects.create_user(email="new@example.com", password="pw-secret-123") self.client.force_login(bare_user)