From b51fef13f40421b4e98b5a8b29894e8f8ac91205 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 28 Mar 2013 09:48:26 +0100 Subject: Minor fix to the /feed view when a feed has no articles. --- source/pyAggr3g470r.py | 9 ++++++--- source/static/templates/feed.html | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index b68c8969..5a55cacf 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -277,7 +277,7 @@ class pyAggr3g470r(object): except KeyError: return self.error("

This feed do not exists.

") - if articles != []: + if articles.count() != 0: today = datetime.datetime.now() last_article = articles[0]["article_date"] first_article = articles[self.mongo.nb_articles(feed_id)-2]["article_date"] @@ -288,14 +288,17 @@ class pyAggr3g470r(object): top_words = utils.top_words(articles = self.mongo.get_articles(feed_id), n=50, size=int(word_size)) tag_cloud = utils.tag_cloud(top_words) - tmpl = lookup.get_template("feed.html") - return tmpl.render(feed=feed, articles=articles, favorites=favorites, \ + tmpl = lookup.get_template("feed.html") + return tmpl.render(feed=feed, articles=articles, favorites=favorites, \ nb_articles_feed=nb_articles_feed, nb_articles_total=nb_articles_total, nb_unread_articles_feed=nb_unread_articles_feed, \ nb_favorites = nb_favorites, first_post_date=first_article, end_post_date=last_article, \ average=average, delta=delta, elapsed=elapsed, \ tag_cloud=tag_cloud, word_size=word_size, \ mail_to=conf.mail_to, mail_notification_enabled=conf.MAIL_ENABLED) + tmpl = lookup.get_template("feed.html") + return tmpl.render(feed=feed, articles=[]) + feed.exposed = True @auth.require() diff --git a/source/static/templates/feed.html b/source/static/templates/feed.html index f4a35e77..bcc1ec6c 100644 --- a/source/static/templates/feed.html +++ b/source/static/templates/feed.html @@ -4,15 +4,21 @@ import utils %>
-

The feed ${feed['feed_title']} contains ${format(nb_articles_feed, ',d')} articles. - Representing ${round((nb_articles_feed / nb_articles_total) * 100, 4)} percent of the total (${format(nb_articles_total, ',d')} articles). -
- Address of the feed: ${feed['feed_link']}. -
- Address of the site: ${feed['site_link']}.

+ %if articles != []: +

The feed ${feed['feed_title']} contains ${format(nb_articles_feed, ',d')} articles. + Representing ${round((nb_articles_feed / nb_articles_total) * 100, 4)} percent of the total (${format(nb_articles_total, ',d')} articles). +
+ Address of the feed: ${feed['feed_link']}. +
+ Address of the site: ${feed['site_link']}.

- %if articles:

${(nb_unread_articles_feed == 0 and ["All articles are read"] or [str(nb_unread_articles_feed) + " unread article" + (nb_unread_articles_feed == 1 and [""] or ["s"])[0]])[0]}.

+ %else: +

No articles for the feed ${feed['feed_title']}. +
+ Address of the feed: ${feed['feed_link']}. +
+ Address of the site: ${feed['site_link']}.

%endif %if feed["mail"] == True: @@ -96,8 +102,6 @@ import utils %endfor ${html} %endif - %else: -

No articles yet.

%endif -- cgit