Skip to content

Commit

Permalink
Fix for empty feeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Apr 29, 2011
1 parent 6b41891 commit f69d191
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions views.py
Expand Up @@ -74,8 +74,11 @@ def feed(basequery=None, type=None, category=None):
title = type.title
elif category:
title = category.title
posts = getposts(basequery)
updated = posts[0].datetime.isoformat()+'Z'
posts = list(getposts(basequery))
if posts: # Can't do this unless posts is a list
updated = posts[0].datetime.isoformat()+'Z'
else:
updated = datetime.utcnow().isoformat()+'Z'
return Response(render_template('feed.xml', posts=posts, updated=updated, title=title),
content_type = 'application/atom+xml; charset=utf-8')

Expand All @@ -94,7 +97,7 @@ def feed_by_type(slug):
@app.route('/category/<slug>/feed')
def feed_by_category(slug):
if slug == 'all':
return redirect(url_for('index'))
return redirect(url_for('feed'))
ob = JobCategory.query.filter_by(slug=slug).first()
if not ob:
abort(404)
Expand Down

0 comments on commit f69d191

Please sign in to comment.