From 143de38d7e50e23f6f8d7977692b218f45c6753d Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 4 Mar 2012 09:06:43 +0100 Subject: Unread articles page is now completely working. Improvements of the get_articles_from_collection() function in mongodb.py, the function takes now an aditional argument in order to filter the result. --- pyAggr3g470r.py | 88 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 40 deletions(-) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 53a283a1..047bf447 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -753,52 +753,30 @@ class Root: """ This page displays all unread articles of a feed. """ + feeds = self.articles.get_all_collections() html = htmlheader() html += htmlnav html += """
""" - if self.nb_unread_articles != 0: + if self.articles.nb_unread_articles() != 0: + + # List unread articles of all the database if feed_id == "": html += "

Unread article(s)

" html += """\n
\nMark articles as read\n
\n""" - for feed in self.feeds.values(): + for feed in feeds: new_feed_section = True nb_unread = 0 - for article in feed.articles.values(): - if article.article_readed == "0": - nb_unread += 1 - if new_feed_section is True: - new_feed_section = False - html += """

%s

\n""" % \ - (feed.feed_id, feed.feed_site_link, feed.feed_title, feed.feed_link, feed.feed_image) - - # descrition for the CSS ToolTips - article_content = utils.clear_string(article.article_description) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article.article_date + " - " + \ - """%s%s
\n""" % \ - (feed.feed_id, article.article_id, article.article_title[:150], description) - - if nb_unread == feed.nb_unread_articles: - html += """
\nMark all articles from this feed as read\n""" % \ - (feed.feed_id,) - html += """
\nMark articles as read\n""" - else: - try: - feed = self.feeds[feed_id] - except: - self.error_page("This feed do not exists.") - html += """

Unread article(s) of the feed %s

-
""" % (feed.feed_id, feed.feed_title) - for article in feed.articles.values(): - if article.article_readed == "0": + + # For all unread article of the current feed. + for article in self.articles.get_articles_from_collection(feed["feed_id"], condition=("article_readed", False)): + nb_unread += 1 + if new_feed_section is True: + new_feed_section = False + html += """

%s

\n""" % \ + (feed["feed_id"], feed["site_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) + # descrition for the CSS ToolTips - article_content = utils.clear_string(article.article_description) + article_content = utils.clear_string(article["article_content"]) if article_content: description = " ".join(article_content[:500].split(' ')[:-1]) else: @@ -806,11 +784,41 @@ class Root: # a description line per article (date, title of the article and # CSS description tooltips on mouse over) - html += article.article_date + " - " + \ + html += str(article["article_date"]) + " - " + \ """%s%s
\n""" % \ - (feed.feed_id, article.article_id, article.article_title[:150], description) + (feed["feed_id"], article["article_id"], article["article_title"][:150], description) + + if nb_unread == self.articles.nb_unread_articles(feed["feed_id"]): + html += """
\nMark all articles from this feed as read\n""" % \ + (feed["feed_id"],) + html += """
\nMark articles as read\n""" + + # List unread articles of a feed + else: + try: + feed = self.articles.get_collection(feed_id) + except: + self.error_page("This feed do not exists.") + html += """

Unread article(s) of the feed %s

+
""" % (feed_id, feed["feed_title"]) + + # For all unread article of the feed. + for article in self.articles.get_articles_from_collection(feed_id, condition=("article_readed", False)): + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += str(article["article_date"]) + " - " + \ + """%s%s
\n""" % \ + (feed_id, article["article_id"], article["article_title"][:150], description) - html += """
\nMark all as read""" % (feed.feed_id,) + html += """
\nMark all as read""" % (feed_id,) + # No unread article else: html += '

No unread article(s)

\n
\nWhy not check for news?' html += """\n

All feeds

""" -- cgit