From 71c72ce09f82c0c936a1c82be4d3681a4d1e133f Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Mon, 29 Mar 2010 07:09:07 +0200 Subject: Added list_notification page to manage the list of watched feeds (by mail). --- pyAggr3g470r.py | 114 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 44 deletions(-) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 8a69d794..4de1e6b3 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -63,33 +63,8 @@ class Root: """ html = htmlheader html += htmlnav - html += """
\n""" - html += """Management
\n""" - html += """Fetch all feeds
\n""" - html += """Mark articles as read\n""" - html += """
\n""" - html += "
\n" - html += """Your feeds (%s):
\n""" % len(self.articles.keys()) - for rss_feed_id in self.articles.keys(): - - if self.feeds[rss_feed_id][1] != 0: - # not readed articles are in bold - not_read_begin = "" - not_read_end = "" - else: - not_read_begin = "" - not_read_end = "" - - html += """%s (%s%s%s / %s)
\n""" % \ - (rss_feed_id.encode('utf-8'), \ - self.feeds[rss_feed_id][3].encode('utf-8'), \ - rss_feed_id, not_read_begin, \ - self.feeds[rss_feed_id][1], not_read_end, \ - self.feeds[rss_feed_id][0]) - - html += """
\n
\n""" + html += self.create_right_menu() + html += """
\n""" for rss_feed_id in self.articles.keys(): html += """

\n""" + html += """Management
\n""" + html += """Fetch all feeds
\n""" + html += """Mark articles as read\n""" + html += """
\n""" + html += "
\n" + html += self.create_list_of_feeds() + html += "

\n" + return html + + def create_list_of_feeds(self): + """ + Create the list of feeds. + """ + html = """Your feeds (%s):
\n""" % len(self.articles.keys()) + for rss_feed_id in self.articles.keys(): + if self.feeds[rss_feed_id][1] != 0: + # not readed articles are in bold + not_read_begin = "" + not_read_end = "" + else: + not_read_begin = "" + not_read_end = "" + html += """%s (%s%s%s / %s)
\n""" % \ + (rss_feed_id.encode('utf-8'), \ + self.feeds[rss_feed_id][3].encode('utf-8'), \ + rss_feed_id, not_read_begin, \ + self.feeds[rss_feed_id][1], not_read_end, \ + self.feeds[rss_feed_id][0]) + return html + + def management(self): """ Management of articles. """ html = htmlheader html += htmlnav - html += """
\n""" + html += """
\n""" html += "

Add Feeds

\n" html += """
\n
\n""" @@ -157,6 +170,7 @@ class Root: html += """\t\n""" % \ (feed_id, self.feeds[feed_id][3].encode('utf-8')) html += """\n""" + html += """

Active e-mail notifications

\n""" html += "
\n" html += """

The database contains a total of %s article(s) with @@ -222,7 +236,7 @@ class Root: feed_id, _, querystring = value.partition(':') html = htmlheader html += htmlnav - html += """

""" + html += """
""" html += """

Articles containing the string %s


""" % (querystring,) @@ -300,7 +314,7 @@ class Root: return self.error_page("This feed do not exists.") html = htmlheader html += htmlnav - html += """
""" + html += """
""" for article in articles_list: if article_id == article[0]: @@ -370,14 +384,7 @@ class Root: html += """
\n
\n""" % (feed_id,) html += "
\n" - html += """Your feeds (%s):
\n""" % len(self.articles.keys()) - for rss_feed_id in self.articles.keys(): - - html += """%s (%s / %s)
\n""" % \ - (rss_feed_id.encode('utf-8'), \ - self.feeds[rss_feed_id][3].encode('utf-8'), \ - rss_feed_id, self.feeds[rss_feed_id][1], \ - self.feeds[rss_feed_id][0]) + html += self.create_list_of_feeds() html += """
""" html += """

Articles of the feed %s


""" % (self.feeds[feed_id][3].encode('utf-8')) @@ -413,8 +420,7 @@ class Root: """ html = htmlheader html += htmlnav - html += """
""" - + html += """
""" if feed_id == "All": html += "

Unread article(s)

" for rss_feed_id in self.feeds.keys(): @@ -440,7 +446,6 @@ class Root: """ - %s""" % \ (feed_id, article[0].encode('utf-8'), article[2].encode('utf-8')) + \ "
\n" - html += """
\nMark all as read""" % (feed_id,) html += """\n

All feeds

""" html += "
\n" @@ -458,7 +463,7 @@ class Root: return self.error_page('This language is not supported.') html = htmlheader html += htmlnav - html += """
""" + html += """
""" html += """

Article(s) written in %s

\n
\n""" % (lang,) if "oice" not in utils.IMPORT_ERROR: for rss_feed_id in self.articles.keys(): @@ -494,7 +499,7 @@ class Root: return self.error_page("This feed do not exists.") html = htmlheader html += htmlnav - html += """
""" + html += """
""" feed_id, article_id = target.split(':') for article in articles_list: if article_id == article[0]: @@ -518,7 +523,7 @@ class Root: """ html = htmlheader html += htmlnav - html += """
""" + html += """
""" html += """%s""" % message html += "\n
\n" + htmlfooter return html @@ -563,6 +568,27 @@ class Root: mark_as_read.exposed = True + def list_notification(self): + """ + List all active e-mail notifications. + """ + html = htmlheader + html += htmlnav + html += """
""" + html += "

You are receiving e-mails for the following feeds:

\n" + for rss_feed_id in self.feeds.keys(): + if self.feeds[rss_feed_id][6] == "1": + html += """\t%s - Stop
\n""" % \ + (rss_feed_id, self.feeds[rss_feed_id][3].encode('utf-8'), rss_feed_id) + + html += """

Notifications are sent to: %s

""" % \ + (utils.mail_to, utils.mail_to) + html += "\n
\n" + htmlfooter + return html + + list_notification.exposed = True + + def mail_notification(self, param): """ Enable or disable to notifications of news for a feed. -- cgit