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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ECGMEwrc2k4D8VQuwjstj9
This commit is contained in:
@@ -126,12 +126,12 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if news_items %}
|
||||
<div>
|
||||
<div class="mb-2.5 flex items-baseline justify-between">
|
||||
<span class="font-display text-xs font-extrabold text-muted uppercase tracking-wide">{% trans "Club news" %}</span>
|
||||
<a class="text-xs font-semibold text-club" href="{% url "mobile:news_list" %}">{% trans "All news" %}</a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-2.5 flex items-baseline justify-between">
|
||||
<span class="font-display text-xs font-extrabold text-muted uppercase tracking-wide">{% trans "Club news" %}</span>
|
||||
<a class="text-xs font-semibold text-club" href="{% url "mobile:news_list" %}">{% trans "All news" %}</a>
|
||||
</div>
|
||||
{% if news_items %}
|
||||
{% with lead=news_items.0 %}
|
||||
<a class="m-card block overflow-hidden" href="{% url "mobile:news_detail" lead.slug %}">
|
||||
<div class="flex h-[104px] items-center justify-center bg-line text-xs text-dim">{% trans "News photo" %}</div>
|
||||
@@ -156,10 +156,14 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="m-card p-6 text-center">
|
||||
<p class="text-sm text-muted">{% trans "No news yet." %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% 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 %}
|
||||
<div class="m-card p-6 text-center">
|
||||
<p class="text-sm text-muted">{% trans "Nothing to show right now." %}</p>
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user