Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support new class based view for feeds.

  • Loading branch information...
commit d2153735437859e3ddae1aeb0ef0f4cd2bb00f07 1 parent 9ff91b6
@friedelwolff friedelwolff authored
View
4 local_apps/pootle_app/templates/index/index.html
@@ -6,7 +6,7 @@
{% get_current_language_bidi as LANGUAGE_BIDI %}
{% block extra_head %}
-<link rel="alternate" type="application/rss+xml" href="{% url pootle_notifications.feeds.view "" %}" />
+<link rel="alternate" type="application/rss+xml" href="{% url pootle_notifications__feed "" %}" />
{% endblock %}
{% block body.id %}frontpage{% endblock body.id %}
@@ -90,7 +90,7 @@
<div class="hd"><h2>{% trans 'Latest News' %}</h2></div>
<div class="bd">
{% render_latest_news "" 5 %}
- <p class="subscribe"><a href="{% url pootle_notifications.feeds.view "" %}">{% trans "Subscribe to the RSS feed." %}</a></p>
+ <p class="subscribe"><a href="{% url pootle_notifications__feed "" %}">{% trans "Subscribe to the RSS feed." %}</a></p>
</div>
</div>
View
31 local_apps/pootle_notifications/feeds.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright 2009 Zuza Software Foundation
+# Copyright 2009-2010,2012 Zuza Software Foundation
#
# This file is part of Pootle.
#
@@ -19,8 +19,7 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
from django.core.exceptions import PermissionDenied
-from django.contrib.syndication.feeds import Feed
-from django.http import HttpResponse
+from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
from pootle_misc.baseurl import l
@@ -31,33 +30,25 @@
from pootle_notifications.models import Notice
from pootle_notifications.views import directory_to_title
-def view(request, path):
- pootle_path = '/%s' % path
- directory = get_object_or_404(Directory, pootle_path=pootle_path)
-
- request.permissions = get_matching_permissions(get_profile(request.user), directory)
- if not check_permission('view', request):
- raise PermissionDenied
-
- feedgen = NoticeFeed(pootle_path, request, directory).get_feed(path)
- response = HttpResponse(mimetype=feedgen.mime_type)
- feedgen.write(response, 'utf-8')
- return response
class NoticeFeed(Feed):
title_template = "notice_title.html"
description_template = "notice_body.html"
- def __init__(self, slug, request, directory):
- self.link = l(directory.pootle_path)
+
+ def get_object(self, request, path):
+ pootle_path = '/%s' % path
+ directory = get_object_or_404(Directory, pootle_path=pootle_path)
+ request.permissions = get_matching_permissions(get_profile(request.user), directory)
+ if not check_permission('view', request):
+ raise PermissionDenied
self.directory = directory
+ self.link = l(directory.pootle_path)
self.recusrive = request.GET.get('all', False)
- super(NoticeFeed, self).__init__(slug, request)
- def get_object(self, bits):
return self.directory
def title(self, directory):
- return directory_to_title(self.request, directory)
+ return directory_to_title(directory)
def items(self, directory):
if self.recusrive:
View
2  local_apps/pootle_notifications/templates/notices.html
@@ -40,7 +40,7 @@
{% endblock %}
{% block extra_head %}
-<link rel="alternate" type="application/rss+xml" title="{{ title }}" href="{% url pootle_notifications.feeds.view path %}" />
+<link rel="alternate" type="application/rss+xml" title="{{ title }}" href="{% url pootle_notifications__feed path %}" />
{% endblock %}
{% block bodyclass %}
View
6 local_apps/pootle_notifications/urls.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright 2009 Zuza Software Foundation
+# Copyright 2009,2012 Zuza Software Foundation
#
# This file is part of Pootle.
#
@@ -20,9 +20,11 @@
from django.conf.urls.defaults import *
+from pootle_notifications import feeds
+
urlpatterns = patterns('pootle_notifications',
- (r'^(?P<path>.*)notices/rss.xml$', 'feeds.view'),
+ url(r'^(?P<path>.*)notices/rss.xml$', feeds.NoticeFeed(), name="pootle_notifications__feed"),
(r'^(?P<path>.*)notices/?$', 'views.view'),
(r'^(?P<path>.*)notices/(?P<notice_id>[0-9]+)/?$', 'views.view_notice_item'),
)
View
6 local_apps/pootle_notifications/views.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright 2009 Zuza Software Foundation
+# Copyright 2009-2012 Zuza Software Foundation
#
# This file is part of Pootle.
#
@@ -51,7 +51,7 @@ def view(request, path):
if check_permission('administrate', request):
template_vars['form'] = handle_form(request, directory)
- template_vars['title'] = directory_to_title(request, directory)
+ template_vars['title'] = directory_to_title(directory)
if request.GET.get('all', False):
template_vars['notices'] = Notice.objects.filter(directory__pootle_path__startswith=directory.pootle_path).select_related('directory')[:30]
else:
@@ -69,7 +69,7 @@ def view(request, path):
return render_to_response('notices.html', template_vars, context_instance=RequestContext(request))
-def directory_to_title(request, directory):
+def directory_to_title(directory):
"""figures out if directory refers to a Language or
TranslationProject and returns appropriate string for use in
titles"""
View
2  templates/language_base.html
@@ -12,7 +12,7 @@
{% endblock %}
{% block extra_head %}
-<link rel="alternate" type="application/rss+xml" href="{% url pootle_notifications.feeds.view feed_path %}" />
+<link rel="alternate" type="application/rss+xml" href="{% url pootle_notifications__feed feed_path %}" />
{% endblock %}
{% block precontent %}
View
2  templates/tp_base.html
@@ -23,7 +23,7 @@
{% endblock %}
{% block extra_head %}
-<link rel="alternate" type="application/rss+xml" href="{% url pootle_notifications.feeds.view feed_path %}" />
+<link rel="alternate" type="application/rss+xml" href="{% url pootle_notifications__feed feed_path %}" />
{% endblock %}
{% block search %}
Please sign in to comment.
Something went wrong with that request. Please try again.