From b08f8a6891de0879148d4801b4893991b8ea628a Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 4 Mar 2012 00:00:11 +0100 Subject: Mark as read for a feed is working. --- mongodb.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'mongodb.py') diff --git a/mongodb.py b/mongodb.py index 3c03c8ed..bc318add 100644 --- a/mongodb.py +++ b/mongodb.py @@ -120,15 +120,26 @@ class Articles(object): for feed_id in self.db.collection_names(): unread_articles += self.nb_unread_articles(feed_id) return unread_articles - - + def like_article(self, like, feed_id, article_id): """ Like or unlike an article. """ collection = self.db[str(feed_id)] collection.update({"article_id": article_id}, {"$set": {"article_like": like}}) - + + def mark_as_read(self, readed, feed_id=None, article_id=None): + """ + """ + if feed_id != None and article_id != None: + collection = self.db[str(feed_id)] + collection.update({"article_id": article_id}, {"$set": {"article_readed": readed}}) + elif feed_id != None and article_id == None: + collection = self.db[str(feed_id)] + collection.update({"type": 1}, {"$set": {"article_readed": readed}}, multi=True) + else: + collection.update({"article_id": article_id}, {"$set": {"article_readed": readed}}) + def list_collections(self): """ List all collections (feed). -- cgit