diff --git a/apps/activity/feeds.py b/apps/activity/feeds.py new file mode 100644 index 0000000..9e97e74 --- /dev/null +++ b/apps/activity/feeds.py @@ -0,0 +1,42 @@ +from django.contrib.syndication.views import Feed +from django.core.urlresolvers import reverse +from django.shortcuts import get_object_or_404 +from django.utils.translation import ugettext_lazy as _ +from django.utils.feedgenerator import Atom1Feed + +from activity.models import Activity +from users.models import UserProfile + + +class UserActivityFeed(Feed): + """Atom feed of user activities.""" + + feed_type = Atom1Feed + + def author_name(self, user): + return user.name + + def title(self, user): + return user.name + + def subtitle(self, user): + return _('Activity feed for %s' % (user.name,)) + + def link(self, user): + return reverse('users_profile_view', + kwargs={'username': user.username}) + + def get_object(self, request, username): + return get_object_or_404(UserProfile, username=username) + + def items(self, user): + return Activity.objects.filter(actor=user)[:25] + + def item_title(self, item): + return item.verb + + def item_description(self, item): + return u"%s activity performed by %s" % (item.verb, item.actor.name) + + def item_link(self, item): + return u'http://blah.com' diff --git a/apps/activity/urls.py b/apps/activity/urls.py index 642eaef..bf37f1d 100644 --- a/apps/activity/urls.py +++ b/apps/activity/urls.py @@ -1,9 +1,13 @@ from django.conf.urls.defaults import patterns, url +from activity.feeds import UserActivityFeed + urlpatterns = patterns('', - url(r'^(?P[\d]+)/', 'activity.views.index', + url(r'^activity/(?P[\d]+)/', 'activity.views.index', name='activity_index'), - url(r'^delete/$', 'activity.views.delete', + url(r'^activity/delete/$', 'activity.views.delete', name='activity_delete'), + url(r'^(?P[\w-]+)/feed', UserActivityFeed(), + name='activity_user_feed'), ) diff --git a/urls.py b/urls.py index d438d3a..3d6f29b 100644 --- a/urls.py +++ b/urls.py @@ -8,7 +8,7 @@ urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), (r'', include('dashboard.urls')), (r'', include('wellknown.urls')), - (r'^activity/', include('activity.urls')), + (r'', include('activity.urls')), (r'^statuses/', include('statuses.urls')), (r'^projects/', include('projects.urls')), (r'^events/', include('events.urls')),