Skip to content

Hid empty feed type from community page. #1874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions aggregator/tests.py
Original file line number Diff line number Diff line change
@@ -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}
4 changes: 3 additions & 1 deletion aggregator/views.py
Original file line number Diff line number Diff line change
@@ -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)

Loading