From a98707659b4b07791fd82b0b7d64ce46b9f6ad22 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 1 May 2012 10:25:12 +0200 Subject: Minor bugfix: links to previous and following articles were wrong. --- source/pyAggr3g470r.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index a9434fba..fb20d95e 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -479,20 +479,24 @@ class Root: f.save("./var/qrcode/"+article_id+".png") # Previous and following articles - articles_list = articles.distinct("article_id") + previous, following = None, None + liste = self.mongo.get_articles_from_collection(feed_id) + for current_article in self.mongo.get_articles_from_collection(feed_id): + articles.next() + if current_article["article_id"] == article_id: + break + following = current_article + if following is None: + following = liste[liste.count()-1] try: - following = articles[articles_list.index(article_id) - 1] - html += """
\n""" % \ - (feed_id, following["article_id"], following["article_title"]) - except Exception, e: - print e - try: - previous = articles[articles_list.index(article_id) + 1] - except: - previous = articles[0] - finally: - html += """
\n""" % \ - (feed_id, previous["article_id"], previous["article_title"]) + previous = articles.next() + except StopIteration: + previous = liste[0] + + html += """
\n""" % \ + (feed_id, following["article_id"], following["article_title"]) + html += """
\n""" % \ + (feed_id, previous["article_id"], previous["article_title"]) html += "\n\n" -- cgit