From f65f4e936e890dea064628d1a457f0db93ceb757 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 4 Mar 2012 00:26:33 +0100 Subject: Notifications page is working. Improved get_all_collections function. --- mongodb.py | 7 +++++-- pyAggr3g470r.py | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mongodb.py b/mongodb.py index 991ed62b..2da229c8 100644 --- a/mongodb.py +++ b/mongodb.py @@ -64,14 +64,17 @@ class Articles(object): collection = self.db[str(feed_id)] return collection.find({"article_id":article_id}).next() - def get_all_collections(self): + def get_all_collections(self, condition=None): """ """ feeds = [] collections = self.db.collection_names() for collection_name in collections: if collection_name != "system.indexes": - cursor = self.db[collection_name].find({"type":0}) + if condition is None: + cursor = self.db[collection_name].find({"type":0}) + else: + cursor = self.db[collection_name].find({"type":0, condition[0]:condition[1]}) if cursor.count() != 0: feeds.append(cursor.next()) feeds = sorted(feeds, key=itemgetter('feed_title')) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index ccb47150..72c8272e 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -983,11 +983,14 @@ class Root: html = htmlheader() html += htmlnav html += """
""" - html += "

You are receiving e-mails for the following feeds:

\n" - for feed in self.feeds.values(): - if feed.mail == "1": + feeds = self.articles.get_all_collections(condition=("mail",True)) + if feeds != []: + html += "

You are receiving e-mails for the following feeds:

\n" + for feed in feeds: html += """\t%s - Stop
\n""" % \ - (feed.feed_id, feed.feed_title, feed.feed_id) + (feed["feed_id"], feed.feed_title, feed.feed_id) + else: + html += "

No active notifications.

\n" html += """

Notifications are sent to: %s

""" % \ (utils.mail_to, utils.mail_to) html += "\n
\n" + htmlfooter -- cgit