diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-10-13 12:37:17 +0200 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-10-13 12:37:17 +0200 |
commit | 9fdc9836902f0b1bb8cd9f087cdd238b2e96c6de (patch) | |
tree | 8adb38c1f58f2e311c6bde220d2344f63e053451 /pyaggr3g470r/models.py | |
parent | First prototype for the /articles page. (diff) | |
download | newspipe-9fdc9836902f0b1bb8cd9f087cdd238b2e96c6de.tar.gz newspipe-9fdc9836902f0b1bb8cd9f087cdd238b2e96c6de.tar.bz2 newspipe-9fdc9836902f0b1bb8cd9f087cdd238b2e96c6de.zip |
Mark an article as read.
Diffstat (limited to 'pyaggr3g470r/models.py')
-rw-r--r-- | pyaggr3g470r/models.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index a36c27fe..8ce361bb 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -24,21 +24,18 @@ class User(Document, UserMixin): def __unicode__(self): return self.nickname -class Feed(DynamicDocument): +class Feed(Document): title = StringField(required=True) link = StringField(required=True) - image = StringField(required=True) site_link = StringField(required=True) mail = BooleanField() - #articles = ListField(EmbeddedDocumentField('Article')) articles = ListField(ReferenceField('Article', dbref = False)) created_date = DateTimeField(required=True, default=datetime.now) def __unicode__(self): return 'Feed: %s' % self.title -#class Article(EmbeddedDocument): -class Article(DynamicDocument): +class Article(Document): date = DateTimeField(required=True) link = StringField(required=True) title = StringField(required=True) @@ -61,10 +58,9 @@ if __name__ == "__main__": except: pass - import conf import mongodb - mongo = mongodb.Articles(conf.MONGODB_ADDRESS, conf.MONGODB_PORT, \ - conf.MONGODB_DBNAME, conf.MONGODB_USER, conf.MONGODB_PASSWORD) + mongo = mongodb.Articles("127.0.0.1", 27017, \ + "pyaggr3g470r", "***", "") feeds = mongo.get_all_feeds() for feed in feeds: articles = [] @@ -72,7 +68,8 @@ if __name__ == "__main__": for article in mongo.get_articles(feed["feed_id"]): article1 = Article(date=article["article_date"], link=article["article_link"], \ title=article["article_title"], content=article["article_content"], \ - readed=article["article_readed"], like=article["article_like"]) + readed=article["article_readed"], like=article["article_like"], \ + retrieved_date=article["article_date"]) articles.append(article1) try: @@ -82,10 +79,10 @@ if __name__ == "__main__": pass feed1 = Feed(title=feed["feed_title"], link=feed["feed_link"], - image=feed["feed_image"], site_link=feed["site_link"], mail=feed["mail"], + site_link=feed["site_link"], mail=feed["mail"], articles=articles) feed1.save() - for feed in Feed.objects: - print(feed.articles[0].title)
\ No newline at end of file + #for feed in Feed.objects: + #print(feed.articles[0].title)
\ No newline at end of file |