Merge lp:~dylanmccall/harvest/bug-775438 into lp:harvest

Proposed by Dylan McCall
Status: Merged
Merged at revision: 302
Proposed branch: lp:~dylanmccall/harvest/bug-775438
Merge into: lp:harvest
Diff against target: 116 lines (+23/-17)
5 files modified
harvest/opportunities/feeds.py (+11/-7)
harvest/opportunities/urls.py (+9/-7)
harvest/templates/opportunities/filter.html (+1/-1)
harvest/templates/opportunities/include/package_details.html (+1/-1)
harvest/templates/opportunities/single_package.html (+1/-1)
To merge this branch: bzr merge lp:~dylanmccall/harvest/bug-775438
Reviewer Review Type Date Requested Status
Daniel Holbach Approve
Review via email: mp+59673@code.launchpad.net

Description of the change

This fixes bug #775438, switching to the old syndication API. The code is a little uglier, but the URLs stay the same so when the production server is upgraded we won't be tempted to break everyone's RSS feeds :)

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Great work! Thanks a lot for that! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'harvest/opportunities/feeds.py'
2--- harvest/opportunities/feeds.py 2011-05-02 02:39:20 +0000
3+++ harvest/opportunities/feeds.py 2011-05-02 16:30:56 +0000
4@@ -1,5 +1,7 @@
5-from django.contrib.syndication.views import Feed
6+from django.contrib.syndication.feeds import Feed
7+#When Django 1.2 is available, change to new feed API: from django.contrib.syndication.views import Feed
8 from django.core.urlresolvers import reverse
9+from django.core.exceptions import ObjectDoesNotExist
10 from django.shortcuts import get_object_or_404
11 from django.utils.translation import ugettext_lazy as _
12 from django.utils.translation import string_concat
13@@ -26,6 +28,9 @@
14
15 def item_guid(self, opp):
16 return opp.url
17+
18+ def item_pubdate(self, opp):
19+ return opp.since
20
21 class NewestOpportunitiesFeed(_OpportunitiesFeed):
22 def title(self):
23@@ -42,10 +47,12 @@
24 return []
25
26 class SinglePackageFeed(_OpportunitiesFeed):
27- def get_object(self, request, package_name):
28- return get_object_or_404(models.SourcePackage, name=package_name)
29+ def get_object(self, bits):
30+ if len(bits) != 1:
31+ raise ObjectDoesNotExist
32+ return get_object_or_404(models.SourcePackage, name=bits[0])
33
34- def title(self, pkg):
35+ def title(self, pkg):
36 return _("Opportunities for %s in Harvest") % pkg.name
37
38 def link(self, pkg):
39@@ -56,6 +63,3 @@
40
41 def item_title(self, opp):
42 return opp.description
43-
44- def item_guid(self, opp):
45- return opp.url
46
47=== modified file 'harvest/opportunities/urls.py'
48--- harvest/opportunities/urls.py 2011-05-02 02:39:20 +0000
49+++ harvest/opportunities/urls.py 2011-05-02 16:30:56 +0000
50@@ -2,6 +2,11 @@
51
52 import feeds
53
54+feed_dict = {
55+ 'newest25' : feeds.NewestOpportunitiesFeed,
56+ 'package' : feeds.SinglePackageFeed,
57+}
58+
59 urlpatterns = patterns('',
60 url(r'^$',
61 'opportunities.views.filter',
62@@ -39,11 +44,8 @@
63 url(r'^xhr/opportunity/(?P<opportunity_id>[\d]+)/edit/$',
64 'opportunities.views.xhr_opportunity_edit'),
65
66- url(r'^rss/newest25/$',
67- feeds.NewestOpportunitiesFeed(),
68- name='rss_newest_opportunities'),
69-
70- url(r'^rss/package/(?P<package_name>.+)/$',
71- feeds.SinglePackageFeed(),
72- name='rss_single_package'),
73+ url(r'^rss/(?P<url>.*)/$',
74+ 'django.contrib.syndication.views.feed',
75+ {'feed_dict': feed_dict},
76+ name='feed'),
77 )
78
79=== modified file 'harvest/templates/opportunities/filter.html'
80--- harvest/templates/opportunities/filter.html 2011-05-02 02:39:20 +0000
81+++ harvest/templates/opportunities/filter.html 2011-05-02 16:30:56 +0000
82@@ -2,7 +2,7 @@
83 {% load i18n %}
84
85 {% block extrahead %}
86-<link rel="alternate" type="application/rss+xml" title="{% blocktrans %}25 newest opportunities{% endblocktrans %}" href="{% url rss_newest_opportunities %}" />
87+<link rel="alternate" type="application/rss+xml" title="{% blocktrans %}25 newest opportunities{% endblocktrans %}" href="{% url feed 'newest25' %}" />
88 {% endblock %}
89
90 {% block title %}{{ block.super }}{% endblock %}
91
92=== modified file 'harvest/templates/opportunities/include/package_details.html'
93--- harvest/templates/opportunities/include/package_details.html 2011-05-02 00:20:31 +0000
94+++ harvest/templates/opportunities/include/package_details.html 2011-05-02 16:30:56 +0000
95@@ -20,7 +20,7 @@
96 <div class="extra">
97 <div class="actions">
98 <a href="{% url single_package package.real.name %}" target="_blank">{% trans "Permalink" %}</a>
99- <a href="{% url rss_single_package package.real.name %}" target="_blank">{% trans "RSS" %}</a>
100+ <a href="{% url feed 'package' %}{{package.real.name}}/" target="_blank">{% trans "RSS" %}</a>
101 </div>
102 {% with package.get_hidden_opportunities.count as hidden_count %}
103 {% ifnotequal hidden_count 0 %}
104
105=== modified file 'harvest/templates/opportunities/single_package.html'
106--- harvest/templates/opportunities/single_package.html 2011-05-02 01:22:44 +0000
107+++ harvest/templates/opportunities/single_package.html 2011-05-02 16:30:56 +0000
108@@ -2,7 +2,7 @@
109 {% load i18n %}
110
111 {% block extrahead %}
112-<link rel="alternate" type="application/rss+xml" title="{% blocktrans with package.real.name as name %}Opportunities for {{name}}{% endblocktrans %}" href="{% url rss_single_package package.real.name %}" />
113+<link rel="alternate" type="application/rss+xml" title="{% blocktrans with package.real.name as name %}Opportunities for {{name}}{% endblocktrans %}" href="{% url feed 'package' %}{{package.real.name}}/" />
114 {% endblock %}
115
116 {% block title %}{{ block.super }}: {{ package.real.name }}{% endblock %}

Subscribers

People subscribed via source and target branches

to all changes: