From 7da4607b42fd40d709b91a462132681041224488 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 9 Feb 2010 22:03:14 +0100 Subject: Possibility to mark all articles as read only by feeds. --- pyAggr3g470r.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 0a41b2f2..4d49ce7c 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -53,7 +53,7 @@ class Root: html += htmlnav html += """
\n""" html += """Fetch all feeds\n
\n""" - html += """Mark all articles as read\n
\n""" + html += """Mark all articles as read\n
\n""" html += """Management of feed\n""" html += """
\n""" @@ -96,6 +96,7 @@ class Root: html += "
\n" html += """All articles""" % (rss_feed_id,) + html += """ Mark all as read""" % (rss_feed_id,) if self.dic_info[rss_feed_id][1] != 0: html += """ Unread article(s) (%s)""" % (rss_feed_id, \ @@ -130,8 +131,7 @@ class Root: if article_id == article[0]: if article[7] == "0": - self.mark_as_read(article[3]) # update the database - article[7] = "1" # avoids to reload self.dic + self.mark_as_read("Article:"+article[3]) # update the database html += """

%s from %s


""" % \ (article[2].encode('utf-8'), rss_feed_id, article[5].encode('utf-8')) @@ -170,7 +170,8 @@ class Root: not_read_end + \ "
\n" - html += """
\n

All feeds

""" + html += """
\nMark all as read""" % (feed_id,) + html += """\n

All feeds

""" html += "
\n" html += htmlfooter return html @@ -194,7 +195,8 @@ class Root: (article[0].encode('utf-8'), article[2].encode('utf-8')) + \ "
\n" - html += """
\n

All feeds

""" + html += """
\nMark all as read""" % (feed_id,) + html += """\n

All feeds

""" html += "
\n" html += htmlfooter return html @@ -247,23 +249,35 @@ class Root: return (dic, dic_info) return (dic, dic_info) - def mark_as_read(self, article_link = "All"): + def mark_as_read(self, target): """ - Mark an (or all) articles as read by setting the value of the field + Mark one (or more) article(s) as read by setting the value of the field 'article_readed' of the SQLite database to 1. """ + param, identifiant = target.split(':') try: conn = sqlite3.connect("./var/feed.db", isolation_level = None) c = conn.cursor() - if article_link == "All": + # Mark all articles as read. + if param == "All": c.execute("UPDATE rss_feed SET article_readed=1") - else: - c.execute("UPDATE rss_feed SET article_readed=1 WHERE article_link='" + article_link + "'") + # Mark all articles from a feed as read. + elif param == "Feed": + c.execute("UPDATE rss_feed SET article_readed=1 WHERE feed_site_link='" + self.dic[identifiant][0][6] + "'") + # Mark an article as read. + elif param == "Article": + c.execute("UPDATE rss_feed SET article_readed=1 WHERE article_link='" + identifiant + "'") conn.commit() c.close() except Exception, e: pass - return self.index() + + self.dic, self.dic_info = self.load_feed() + + if param == "All": + return self.index() + elif param == "Feed": + return self.all_articles(identifiant) index.exposed = True m.exposed = True -- cgit