Skip to content

Commit

Permalink
Hid empty feed type from community page.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahboyce authored and bmispelon committed Jan 16, 2025
1 parent e51e74b commit f47fa80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions aggregator/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ def test_community_index_number_of_queries(self):
with self.assertNumQueries(6):
self.client.get(url)

def test_empty_feed_type_not_rendered(self):
empty_type = models.FeedType.objects.create(name="Empty", slug="empty")
models.Feed.objects.create(
title="Empty blog",
feed_url="empty.com/rss/",
public_url="empty.com/",
approval_status=models.APPROVED_FEED,
feed_type=empty_type,
)
response = self.client.get(reverse("community-index"))
self.assertNotContains(response, "Empty")

def test_feed_list_only_approved_and_active(self):
url = reverse(
"community-feed-list", kwargs={"feed_type_slug": self.feed_type.slug}
Expand Down
4 changes: 3 additions & 1 deletion aggregator/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def index(request):
"""
feeds = []
for ft in FeedType.objects.all():
feeds.append((ft, ft.items()[0:5]))
recent_items = ft.items()[0:5]
if recent_items:
feeds.append((ft, recent_items))
ctx = {"feedtype_list": feeds}
return render(request, "aggregator/index.html", ctx)

Expand Down

0 comments on commit f47fa80

Please sign in to comment.