Skip to content

Commit aac35ca

Browse files
committed
added a feed for asks
1 parent d3d8f50 commit aac35ca

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

anthill/projects/feeds.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.contrib.syndication import feeds
2-
from anthill.projects.models import Project
2+
from anthill.projects.models import Project, Ask
33

44
class ProjectFeed(feeds.Feed):
55

@@ -25,3 +25,24 @@ def item_pubdate(self, item):
2525
def item_categories(self, item):
2626
return item.tags
2727

28+
29+
class AskFeed(feeds.Feed):
30+
31+
title = 'Latest Asks'
32+
description = 'Latest requests for help from all projects'
33+
link = '/projects/asks/'
34+
35+
title_template = 'projects/ask_feed_title.html'
36+
description_template = 'projects/ask_feed_description.html'
37+
38+
def items(self):
39+
return Ask.objects.select_related()
40+
41+
def item_link(self, item):
42+
return item.project.get_absolute_url()
43+
44+
def item_author_name(self, item):
45+
return item.user
46+
47+
def item_pubdate(self, item):
48+
return item.timestamp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a href="{{obj.project.get_absolute_url}}">{{obj.project}}</a>: {{obj.message}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{obj.project}}: {{obj.message}}

anthill/projects/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.conf.urls.defaults import *
2-
from anthill.projects.feeds import ProjectFeed
2+
from anthill.projects.feeds import ProjectFeed, AskFeed
33

44
urlpatterns = patterns('',
55
url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
66
{'feed_dict': {'latest': ProjectFeed}}, name='project_feeds'),
7+
url(r'^asks/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
8+
{'feed_dict': {'latest': AskFeed}}, name='ask_feed'),
79
)
810

911
urlpatterns += patterns('anthill.projects.views',

0 commit comments

Comments
 (0)