harvest-dev team mailing list archive
-
harvest-dev team
-
Mailing list archive
-
Message #00554
[Merge] lp:~dylanmccall/harvest/rss-feeds into lp:harvest
Dylan McCall has proposed merging lp:~dylanmccall/harvest/rss-feeds into lp:harvest.
Requested reviews:
harvest-dev (harvest-dev)
Related bugs:
Bug #247647 in harvest: "RSS feed on NEW incoming"
https://bugs.launchpad.net/harvest/+bug/247647
For more details, see:
https://code.launchpad.net/~dylanmccall/harvest/rss-feeds/+merge/59635
This should cover what we were looking for in bug #247647. It's at least a start on RSS feeds for Harvest :)
Provides two feeds: one for all opportunities in a single package and one for the newest opportunities (arbitrarily limited to 25). Both feeds are linked in HTML metadata and the package-specific one is linked to beside the permalink button.
--
https://code.launchpad.net/~dylanmccall/harvest/rss-feeds/+merge/59635
Your team harvest-dev is requested to review the proposed merge of lp:~dylanmccall/harvest/rss-feeds into lp:harvest.
=== modified file 'harvest/media/css/style.css'
--- harvest/media/css/style.css 2010-10-12 02:55:53 +0000
+++ harvest/media/css/style.css 2011-05-02 04:04:27 +0000
@@ -437,6 +437,9 @@
text-align:right;
text-transform:lowercase;
}
+.sourcepackage-details > .extra > .actions > a {
+ margin:0px 0.25em;
+}
li.sourcepackage > .sourcepackage-details > .opportunity-list {
=== added file 'harvest/opportunities/feeds.py'
--- harvest/opportunities/feeds.py 1970-01-01 00:00:00 +0000
+++ harvest/opportunities/feeds.py 2011-05-02 04:04:27 +0000
@@ -0,0 +1,61 @@
+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.translation import string_concat
+
+import models
+from wrappers import get_valid_opportunities
+
+class _OpportunitiesFeed(Feed):
+ def item_title(self, opp):
+ return _("%s: %s") % (opp.sourcepackage.name, opp.description)
+
+ def item_description(self, opp):
+ #this is equivalent to the template opportunities/include/opportunity.html.
+ summary_str = ""
+ if len(opp.summary) > 0:
+ #join the strings so they are translated at the right time (not now)
+ summary_str = opp.summary[0]
+ for s in opp.summary[1:]:
+ summary_str = string_concat(summary_str, _(", "), s)
+ return summary_str
+
+ def item_link(self, opp):
+ return opp.url
+
+ def item_guid(self, opp):
+ return opp.url
+
+class NewestOpportunitiesFeed(_OpportunitiesFeed):
+ def title(self):
+ return _("Newest opportunities in Harvest")
+
+ def link(self):
+ return reverse('filter')
+
+ def items(self):
+ valid_opps = get_valid_opportunities(models.Opportunity.objects.order_by('-last_updated'))[:25]
+ if (valid_opps):
+ return valid_opps
+ else:
+ return []
+
+class SinglePackageFeed(_OpportunitiesFeed):
+ def get_object(self, request, package_name):
+ return get_object_or_404(models.SourcePackage, name=package_name)
+
+ def title(self, pkg):
+ return _("Opportunities for %s in Harvest") % pkg.name
+
+ def link(self, pkg):
+ return reverse('single_package', args=[pkg.name])
+
+ def items(self, pkg):
+ return get_valid_opportunities(pkg.opportunity_set.order_by('-last_updated'))
+
+ def item_title(self, opp):
+ return opp.description
+
+ def item_guid(self, opp):
+ return opp.url
=== modified file 'harvest/opportunities/urls.py'
--- harvest/opportunities/urls.py 2011-01-14 21:32:09 +0000
+++ harvest/opportunities/urls.py 2011-05-02 04:04:27 +0000
@@ -1,5 +1,7 @@
from django.conf.urls.defaults import *
+import feeds
+
urlpatterns = patterns('',
url(r'^$',
'opportunities.views.filter',
@@ -36,4 +38,12 @@
url(r'^xhr/opportunity/(?P<opportunity_id>[\d]+)/edit/$',
'opportunities.views.xhr_opportunity_edit'),
+
+ url(r'^rss/newest25/$',
+ feeds.NewestOpportunitiesFeed(),
+ name='rss_newest_opportunities'),
+
+ url(r'^rss/package/(?P<package_name>.+)/$',
+ feeds.SinglePackageFeed(),
+ name='rss_single_package'),
)
=== modified file 'harvest/templates/opportunities/filter.html'
--- harvest/templates/opportunities/filter.html 2010-08-06 20:27:49 +0000
+++ harvest/templates/opportunities/filter.html 2011-05-02 04:04:27 +0000
@@ -1,6 +1,10 @@
{% extends "base.html" %}
{% load i18n %}
+{% block extrahead %}
+<link rel="alternate" type="application/rss+xml" title="{% blocktrans %}25 newest opportunities{% endblocktrans %}" href="{% url rss_newest_opportunities %}" />
+{% endblock %}
+
{% block title %}{{ block.super }}{% endblock %}
{% block content %}
=== modified file 'harvest/templates/opportunities/include/package_details.html'
--- harvest/templates/opportunities/include/package_details.html 2010-08-11 23:36:17 +0000
+++ harvest/templates/opportunities/include/package_details.html 2011-05-02 04:04:27 +0000
@@ -20,6 +20,7 @@
<div class="extra">
<div class="actions">
<a href="{% url single_package package.real.name %}" target="_blank">{% trans "Permalink" %}</a>
+ <a href="{% url rss_single_package package.real.name %}" target="_blank">{% trans "RSS" %}</a>
</div>
{% with package.get_hidden_opportunities.count as hidden_count %}
{% ifnotequal hidden_count 0 %}
=== modified file 'harvest/templates/opportunities/single_package.html'
--- harvest/templates/opportunities/single_package.html 2010-08-06 03:34:17 +0000
+++ harvest/templates/opportunities/single_package.html 2011-05-02 04:04:27 +0000
@@ -1,6 +1,10 @@
{% extends "one_column.html" %}
{% load i18n %}
+{% block extrahead %}
+<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 %}" />
+{% endblock %}
+
{% block title %}{{ block.super }}: {{ package.real.name }}{% endblock %}
{% block pagetitle %}{{ package.real.name }}{% endblock %}