Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Restored rss/community/ feed to its old behavior (just blogs).

There's a new rss/community/firehose/ for the everything feed.
  • Loading branch information...
commit 8a5abeba9ed6ba39948e6407bbf3f98b05ccf8a7 1 parent 14eff7b
@jacobian jacobian authored
Showing with 35 additions and 30 deletions.
  1. +31 −28 django_website/aggregator/feeds.py
  2. +4 −2 django_website/urls/www.py
View
59 django_website/aggregator/feeds.py
@@ -5,34 +5,7 @@
from django.shortcuts import get_object_or_404
from .models import FeedType, FeedItem
-class CommunityAggregatorFeed(Feed):
- description = "Aggregated feeds from the Django community."
-
- def get_object(self, request, slug=None):
- if slug:
- return get_object_or_404(FeedType, slug=slug)
- return None
-
- def title(self, obj):
- title = obj.name if obj else "firehose"
- return "Django community aggregator: %s" % title
-
- def link(self, obj):
- if obj:
- return urlresolvers.reverse('aggregator-feed', args=[obj.slug])
- else:
- return urlresolvers.reverse('aggregator-firehose-feed')
-
- def description(self, obj):
- return self.title(obj)
-
- def items(self, obj):
- qs = FeedItem.objects.order_by('-date_modified')
- qs = qs.select_related('feed', 'feed__feed_type')
- if obj:
- qs = qs.filter(feed__feed_type=obj)
- return qs[:25]
-
+class BaseCommunityAggregatorFeed(Feed):
def item_title(self, item):
return item.title
@@ -53,3 +26,33 @@ def item_author_link(self, item):
def item_pubdate(self, item):
return item.date_modified
+
+class CommunityAggregatorFeed(BaseCommunityAggregatorFeed):
+ def get_object(self, request, slug=None):
+ return get_object_or_404(FeedType, slug=slug)
+
+ def items(self, obj):
+ qs = FeedItem.objects.filter(feed__feed_type=obj)
+ qs = qs.order_by('-date_modified')
+ qs = qs.select_related('feed', 'feed__feed_type')
+ return qs[:25]
+
+ def title(self, obj):
+ return "Django community aggregator: %s" % obj.name
+
+ def link(self, obj):
+ return urlresolvers.reverse('aggregator-feed', args=[obj.slug])
+
+ def description(self, obj):
+ return self.title(obj)
+
+class CommunityAggregatorFirehoseFeed(BaseCommunityAggregatorFeed):
+ title = 'Django community aggregator firehose'
+ description = 'All activity from the Django community aggregator'
+
+ def link(self):
+ return urlresolvers.reverse('aggregator-firehose-feed')
+
+ def items(self):
+ qs = FeedItem.objects.order_by('-date_modified').select_related('feed')
+ return qs[:50]
View
6 django_website/urls/www.py
@@ -7,7 +7,8 @@
from django.contrib.comments.models import Comment
from django.contrib.sitemaps import views as sitemap_views
from django.views.decorators.cache import cache_page
-from ..aggregator.feeds import CommunityAggregatorFeed
+from django.views.generic.simple import redirect_to
+from ..aggregator.feeds import CommunityAggregatorFeed, CommunityAggregatorFirehoseFeed
from ..aggregator.models import FeedItem
from ..blog.feeds import WeblogEntryFeed
from ..sitemaps import FlatPageSitemap, WeblogSitemap
@@ -40,7 +41,8 @@
url(r'^rss/weblog/$', WeblogEntryFeed(), name='weblog-feed'),
url(r'^rss/comments/$', LatestCommentFeed(), name='comments-feed'),
- url(r'^rss/community/$', CommunityAggregatorFeed(), name='aggregator-firehose-feed'),
+ url(r'^rss/community/$', redirect_to, {'url': '/rss/community/blogs/'}),
+ url(r'^rss/community/firehose/$', CommunityAggregatorFirehoseFeed(), name='aggregator-firehose-feed'),
url(r'^rss/community/(?P<slug>[\w-]+)/$', CommunityAggregatorFeed(), name='aggregator-feed'),
url(r'^sitemap\.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6), {'sitemaps': sitemaps}),
Please sign in to comment.
Something went wrong with that request. Please try again.