Changeset - 252f29af8119
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 10 years ago 2014-07-14 15:56:30
bkuhn@ebb.org
Make sure return values match title.

I received this error from the feeds:

AttributeError at /feeds/news/

'PressRelease' object has no attribute 'title'

Request Method: GET
Request URL: http://sfconservancy.org/feeds/news/
Django Version: 1.4.5
Exception Type: AttributeError

'PressRelease' object has no attribute 'title'
Exception Location: /var/www/conservancy/feeds.py in item_title, line 46

I think this change fixes that.
1 file changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
www/conservancy/feeds.py
Show inline comments
...
 
@@ -34,28 +34,28 @@ class ConservancyFeedBase(Feed):
 
        return { 'year' : year }
 

	
 
class PressReleaseFeed(Feed):
 
    get_absolute_url = '/feeds/news/'
 
    title = "Software Freedom Conservancy News"
 
    link = "/news/"
 
    description = ""
 

	
 
    def items(self):
 
        return PressRelease.objects.filter(pub_date__lte=datetime.now(),
 
                                           sites__id__exact=settings.SITE_ID).order_by('-pub_date')[:10]
 
    def item_title(self, item):
 
        return item.title
 
        return item.headline
 

	
 
    def item_description(self, item):
 
        return item.title
 
        return item.summary
 

	
 
    def item_pubdate(self, item):
 
        return item.pub_date
 

	
 
class OmnibusFeedType(Rss201rev2Feed):
 
    def root_attributes(self):
 
        attrs = super(OmnibusFeedType, self).root_attributes()
 
        attrs['xmlns:itunes'] = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
 
        attrs['xmlns:atom'] = 'http://www.w3.org/2005/Atom'
 
        attrs['xmlns:media'] = 'http://search.yahoo.com/mrss/'
 
        attrs['xmlns:dc'] = "http://purl.org/dc/elements/1.1/"
 
        return attrs
...
 
@@ -73,28 +73,28 @@ class OmnibusFeed(ConservancyFeedBase):
 
    get_absolute_url = '/feeds/omnibus/'
 
    feed_type = OmnibusFeedType
 
    link ="/news/"
 
    title = "The Software Freedom Conservancy"
 
    description = "An aggregated feed of all RSS content available from the Software Freedom Conservancy, including both news items and blogs."
 
    title_template = "feeds/omnibus_title.html"
 
    description_template = "feeds/omnibus_description.html"
 
    author_email = "info@sfconservancy.org"
 
    author_link = "https://sfconservancy.org/"
 
    author_name = "Software Freedom Conservancy"
 

	
 
    def item_title(self, item):
 
        return item.title
 
        return item.headline
 

	
 
    def item_description(self, item):
 
        return item.description
 
        return item.summary
 

	
 
    def item_enclosure_mime_type(self): return "audio/mpeg"
 

	
 
    def item_enclosure_url(self, item):
 
        if hasattr(item, 'mp3_path'):
 
            return "https://sfconservancy.org" + item.mp3_path
 
    def item_enclosure_length(self, item):
 
        if hasattr(item, 'mp3_path'):
 
            return item.mp3_length
 

	
 
    def item_pubdate(self, item):
 
        return item.pub_date
...
 
@@ -202,28 +202,28 @@ class BlogFeed(ConservancyFeedBase):
 
                    firstTime = False
 
                else:
 
                    answer += " or "
 
                answer += tag
 
                done[tag] = tag
 
        else:
 
            answer = "All blogs at the Software Freedom Conservancy"
 
        answer += "."
 

	
 
        return answer
 
        
 
    def item_title(self, item):
 
        return item.title
 
        return item.headline
 

	
 
    def item_description(self, item):
 
        return item.description
 
        return item.summary
 

	
 
    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
0 comments (0 inline, 0 general)