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
=== modified file 'harvest/opportunities/feeds.py'
--- harvest/opportunities/feeds.py 2011-05-02 02:39:20 +0000
+++ harvest/opportunities/feeds.py 2011-05-02 16:30:56 +0000
@@ -1,5 +1,7 @@
1from django.contrib.syndication.views import Feed1from django.contrib.syndication.feeds import Feed
2#When Django 1.2 is available, change to new feed API: from django.contrib.syndication.views import Feed
2from django.core.urlresolvers import reverse3from django.core.urlresolvers import reverse
4from django.core.exceptions import ObjectDoesNotExist
3from django.shortcuts import get_object_or_4045from django.shortcuts import get_object_or_404
4from django.utils.translation import ugettext_lazy as _6from django.utils.translation import ugettext_lazy as _
5from django.utils.translation import string_concat7from django.utils.translation import string_concat
@@ -26,6 +28,9 @@
26 28
27 def item_guid(self, opp):29 def item_guid(self, opp):
28 return opp.url30 return opp.url
31
32 def item_pubdate(self, opp):
33 return opp.since
2934
30class NewestOpportunitiesFeed(_OpportunitiesFeed):35class NewestOpportunitiesFeed(_OpportunitiesFeed):
31 def title(self):36 def title(self):
@@ -42,10 +47,12 @@
42 return []47 return []
4348
44class SinglePackageFeed(_OpportunitiesFeed):49class SinglePackageFeed(_OpportunitiesFeed):
45 def get_object(self, request, package_name):50 def get_object(self, bits):
46 return get_object_or_404(models.SourcePackage, name=package_name)51 if len(bits) != 1:
52 raise ObjectDoesNotExist
53 return get_object_or_404(models.SourcePackage, name=bits[0])
47 54
48 def title(self, pkg): 55 def title(self, pkg):
49 return _("Opportunities for %s in Harvest") % pkg.name56 return _("Opportunities for %s in Harvest") % pkg.name
50 57
51 def link(self, pkg):58 def link(self, pkg):
@@ -56,6 +63,3 @@
56 63
57 def item_title(self, opp):64 def item_title(self, opp):
58 return opp.description65 return opp.description
59
60 def item_guid(self, opp):
61 return opp.url
6266
=== modified file 'harvest/opportunities/urls.py'
--- harvest/opportunities/urls.py 2011-05-02 02:39:20 +0000
+++ harvest/opportunities/urls.py 2011-05-02 16:30:56 +0000
@@ -2,6 +2,11 @@
22
3import feeds3import feeds
44
5feed_dict = {
6 'newest25' : feeds.NewestOpportunitiesFeed,
7 'package' : feeds.SinglePackageFeed,
8}
9
5urlpatterns = patterns('',10urlpatterns = patterns('',
6 url(r'^$',11 url(r'^$',
7 'opportunities.views.filter',12 'opportunities.views.filter',
@@ -39,11 +44,8 @@
39 url(r'^xhr/opportunity/(?P<opportunity_id>[\d]+)/edit/$',44 url(r'^xhr/opportunity/(?P<opportunity_id>[\d]+)/edit/$',
40 'opportunities.views.xhr_opportunity_edit'),45 'opportunities.views.xhr_opportunity_edit'),
41 46
42 url(r'^rss/newest25/$',47 url(r'^rss/(?P<url>.*)/$',
43 feeds.NewestOpportunitiesFeed(),48 'django.contrib.syndication.views.feed',
44 name='rss_newest_opportunities'),49 {'feed_dict': feed_dict},
45 50 name='feed'),
46 url(r'^rss/package/(?P<package_name>.+)/$',
47 feeds.SinglePackageFeed(),
48 name='rss_single_package'),
49)51)
5052
=== modified file 'harvest/templates/opportunities/filter.html'
--- harvest/templates/opportunities/filter.html 2011-05-02 02:39:20 +0000
+++ harvest/templates/opportunities/filter.html 2011-05-02 16:30:56 +0000
@@ -2,7 +2,7 @@
2{% load i18n %}2{% load i18n %}
33
4{% block extrahead %}4{% block extrahead %}
5<link rel="alternate" type="application/rss+xml" title="{% blocktrans %}25 newest opportunities{% endblocktrans %}" href="{% url rss_newest_opportunities %}" />5<link rel="alternate" type="application/rss+xml" title="{% blocktrans %}25 newest opportunities{% endblocktrans %}" href="{% url feed 'newest25' %}" />
6{% endblock %}6{% endblock %}
77
8{% block title %}{{ block.super }}{% endblock %}8{% block title %}{{ block.super }}{% endblock %}
99
=== modified file 'harvest/templates/opportunities/include/package_details.html'
--- harvest/templates/opportunities/include/package_details.html 2011-05-02 00:20:31 +0000
+++ harvest/templates/opportunities/include/package_details.html 2011-05-02 16:30:56 +0000
@@ -20,7 +20,7 @@
20<div class="extra">20<div class="extra">
21 <div class="actions">21 <div class="actions">
22 <a href="{% url single_package package.real.name %}" target="_blank">{% trans "Permalink" %}</a>22 <a href="{% url single_package package.real.name %}" target="_blank">{% trans "Permalink" %}</a>
23 <a href="{% url rss_single_package package.real.name %}" target="_blank">{% trans "RSS" %}</a>23 <a href="{% url feed 'package' %}{{package.real.name}}/" target="_blank">{% trans "RSS" %}</a>
24 </div>24 </div>
25 {% with package.get_hidden_opportunities.count as hidden_count %}25 {% with package.get_hidden_opportunities.count as hidden_count %}
26 {% ifnotequal hidden_count 0 %}26 {% ifnotequal hidden_count 0 %}
2727
=== modified file 'harvest/templates/opportunities/single_package.html'
--- harvest/templates/opportunities/single_package.html 2011-05-02 01:22:44 +0000
+++ harvest/templates/opportunities/single_package.html 2011-05-02 16:30:56 +0000
@@ -2,7 +2,7 @@
2{% load i18n %}2{% load i18n %}
33
4{% block extrahead %}4{% block extrahead %}
5<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 %}" />5<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}}/" />
6{% endblock %}6{% endblock %}
77
8{% block title %}{{ block.super }}: {{ package.real.name }}{% endblock %}8{% block title %}{{ block.super }}: {{ package.real.name }}{% endblock %}

Subscribers

People subscribed via source and target branches

to all changes: