diff options
author | cedricbonhomme <devnull@localhost> | 2012-03-04 09:47:56 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2012-03-04 09:47:56 +0100 |
commit | 6278d00ed760cd216067dd7977ab874c1d42bb49 (patch) | |
tree | 02a3b8cabb22f0fc978bedde480947ec7974a698 | |
parent | Unread articles page is now completely working. Improvements of the get_artic... (diff) | |
download | newspipe-6278d00ed760cd216067dd7977ab874c1d42bb49.tar.gz newspipe-6278d00ed760cd216067dd7977ab874c1d42bb49.tar.bz2 newspipe-6278d00ed760cd216067dd7977ab874c1d42bb49.zip |
Mamangement page is now almost workink.
-rw-r--r-- | mongodb.py | 30 | ||||
-rwxr-xr-x | pyAggr3g470r.py | 18 |
2 files changed, 36 insertions, 12 deletions
@@ -108,13 +108,35 @@ class Articles(object): """ if feed_id is not None: collection = self.db[feed_id] - return collection.find({"type":1}).count() + cursor = collection.find({'type':1}) + return cursor.count() + else: + nb_articles = 0 + for feed_id in self.db.collection_names(): + nb_articles += self.nb_articles(feed_id) + return nb_articles - def nb_favorites(self): - return "12" + def nb_favorites(self, feed_id=None): + if feed_id is not None: + collection = self.db[feed_id] + cursor = collection.find({'type':1, 'article_like':True}) + return cursor.count() + else: + nb_favorites = 0 + for feed_id in self.db.collection_names(): + nb_favorites += self.nb_favorites(feed_id) + return nb_favorites def nb_mail_notifications(self): - return "42" + """ + Return the number of subscribed feeds. + """ + nb_mail_notifications = 0 + for feed_id in self.db.collection_names(): + collection = self.db[feed_id] + cursor = collection.find({'type':0, 'mail':True}) + nb_mail_notifications += cursor.count() + return nb_mail_notifications def nb_unread_articles(self, feed_id=None): if feed_id is not None: diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 047bf447..4a9280fc 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -251,6 +251,8 @@ class Root: Allows adding and deleting feeds. Export functions of the SQLite data base and display some statistics. """ + feeds = self.articles.get_all_collections() + html = htmlheader() html += htmlnav html += """<div class="left inner">\n""" @@ -258,27 +260,27 @@ class Root: # Form: add a feed html += """<form method=get action="/add_feed/"><input type="url" name="url" placeholder="URL of a site" maxlength=2048 autocomplete="off">\n<input type="submit" value="OK"></form>\n""" - if self.feeds: + if feeds: # Form: delete a feed html += "<h1>Delete Feeds</h1>\n" html += """<form method=get action="/remove_feed/"><select name="feed_id">\n""" - for feed in self.feeds.values(): - html += """\t<option value="%s">%s</option>\n""" % (feed.feed_id, feed.feed_title) + for feed in feeds: + html += """\t<option value="%s">%s</option>\n""" % (feed["feed_id"], feed["feed_title"]) html += """</select><input type="submit" value="OK"></form>\n""" html += """<p>Active e-mail notifications: <a href="/notifications/">%s</a></p>\n""" % \ - (self.nb_mail_notifications,) + (self.articles.nb_mail_notifications(),) html += """<p>You like <a href="/favorites/">%s</a> article(s).</p>\n""" % \ - (self.nb_favorites, ) + (self.articles.nb_favorites(), ) html += "<hr />\n" # Informations about the data base of articles html += """<p>%s article(s) are loaded from the database with <a href="/unread/">%s unread article(s)</a>.<br />\n""" % \ - (self.nb_articles, self.nb_unread_articles) - html += """Database: %s.\n<br />Size: %s bytes.<br />\n""" % \ - (os.path.abspath(utils.sqlite_base), os.path.getsize(utils.sqlite_base)) + (self.articles.nb_articles(), self.articles.nb_unread_articles()) + #html += """Database: %s.\n<br />Size: %s bytes.<br />\n""" % \ + #(os.path.abspath(utils.sqlite_base), os.path.getsize(utils.sqlite_base)) html += '<a href="/statistics/">Advanced statistics.</a></p>\n' html += """<form method=get action="/fetch/">\n<input type="submit" value="Fetch all feeds"></form>\n""" |