Changeset - 6a2918c288c2
[Not reviewed]
0 2 0
Bradley Kuhn (bkuhn) - 10 years ago 2014-07-14 14:49:29
bkuhn@ebb.org
In Django 1.2, feed_dict was deprecated.

Therefore, change this to use the method explained at:

https://docs.djangoproject.com/en/dev/releases/1.2/#feed-in-django-contrib-syndication-feeds
2 files changed with 3 insertions and 10 deletions:
0 comments (0 inline, 0 general)
www/conservancy/feeds.py
Show inline comments
...
 
@@ -193,65 +193,58 @@ class BlogFeed(ConservancyFeedBase):
 
        else:
 
            answer = "All blogs at the Software Freedom Conservancy"
 
        answer += "."
 

	
 
        return answer
 
        
 
    def item_author_name(self, item):
 
        return item.author.formal_name
 

	
 
    def item_author_email(self, item):
 
        GET = self.request.GET
 
        if not 'author' in GET:
 
            return "%s@sfconservancy.org" % item.author
 
        else:
 
            answer = ""
 
            authors = GET.getlist('author')
 
            firstTime = True
 
            for author in authors:
 
                if not firstTime:
 
                    answer = "%s@sfconservancy.org" % author
 
                    firstTime = False
 
                else:
 
                    answer += ",%s@sfconservancy.org" % author
 

	
 
    def item_pubdate(self, item):
 
        return item.pub_date
 
    def items(self):
 
        GET = self.request.GET
 

	
 
        def OR_filter(field_name, subfield_name, objs):
 
            from django.db.models import Q
 
            return reduce(lambda x, y: x | y,
 
                          [Q(**{'%s__%s' % (field_name, subfield_name): x})
 
                           for x in objs])
 

	
 
        queryset = BlogEntry.objects.filter(pub_date__lte=datetime.now())
 

	
 
        if 'author' in GET:
 
            authors = GET.getlist('author')
 
            queryset = queryset.filter(OR_filter('author', 'username', authors))
 

	
 
        if 'tag' in GET:
 
            tags = GET.getlist('tag')
 
            queryset = queryset.filter(OR_filter('tags', 'slug', tags))
 

	
 
        return queryset.order_by('-pub_date')[:10]
 

	
 

	
 
feed_dict = {
 
    'blog': BlogFeed,
 
    'news': PressReleaseFeed,
 
    'omnibus': OmnibusFeed,
 
#    'event-media': RecentEventMediaFeed,
 
}
 
# make each feed know its canonical url
 

	
 
for k, v in feed_dict.items():
 
    v.get_absolute_url = '/feeds/%s/' % k
 

	
 
def view(request):
 
    """Listing of all available feeds
 
    """
 

	
 
    feeds = feed_dict.values()
 
    return render_to_response("feeds.html", {'feeds': feeds})
www/conservancy/urls.py
Show inline comments
 
# Copyright 2005-2008, James Garrison
 
# Copyright 2010, 2012 Bradley M. Kuhn
 

	
 
# This software's license gives you freedom; you can copy, convey,
 
# propagate, redistribute, modify and/or redistribute modified versions of
 
# this program under the terms of the GNU Affero General Public License
 
# (AGPL) as published by the Free Software Foundation (FSF), either
 
# version 3 of the License, or (at your option) any later version of the
 
# AGPL published by the FSF.
 
#
 
# This program is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.conf.urls.defaults import *
 
from conservancy.feeds import feed_dict
 
from django.contrib import admin
 

	
 
handler404 = 'modpythoncustom.view404'
 

	
 
admin.autodiscover()
 

	
 
urlpatterns = patterns('',
 
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
 
    (r'^admin/(.*)', admin.site.urls),
 
    (r'^$', 'conservancy.frontpage.view'),
 
    (r'^feeds/(?P<url>.*)/?$', 'django.contrib.syndication.views.Feed',
 
     {'feed_dict': feed_dict}),
 
    (r'^feeds/blog/?$', 'django.contrib.syndication.views.Feed', BlogFeed()),
 
    (r'^feeds/news/?$', 'django.contrib.syndication.views.Feed', PressReleaseFeed()),
 
    (r'^feeds/omnibus/?$', 'django.contrib.syndication.views.Feed', OmnibusFeed()),
 
    (r'^feeds/?$', 'conservancy.feeds.view'),
 
    (r'^news(/|$)', include('conservancy.apps.news.urls')),
 
    (r'^blog(/|$)', include('conservancy.apps.blog.urls')),
 
)
0 comments (0 inline, 0 general)