diff options
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/feedgetter.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/models.py | 14 | ||||
-rw-r--r-- | pyaggr3g470r/templates/articles.html | 12 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 7 |
4 files changed, 12 insertions, 23 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py index 16571294..998e768a 100644 --- a/pyaggr3g470r/feedgetter.py +++ b/pyaggr3g470r/feedgetter.py @@ -148,7 +148,7 @@ class FeedGetter(object): article_title, description)).start() """ feed.articles.extend(articles) - feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True) + #feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True) feed.save() diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index e9f115d1..58b350ea 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -78,7 +78,7 @@ if __name__ == "__main__": for feed in feeds: articles = [] feed_articles = mongo.get_articles(feed["feed_id"]) - #feed_articles = sorted(feed_articles, key=lambda t: t['article_date'], reverse=True) + feed_articles = sorted(feed_articles, key=lambda t: t['article_date'], reverse=True) for article in feed_articles: article1 = Article(date=article["article_date"], link=article["article_link"], \ title=article["article_title"], content=article["article_content"], \ @@ -86,19 +86,11 @@ if __name__ == "__main__": retrieved_date=article["article_date"]) articles.append(article1) - try: - article1.save() - except: - # pas de méthode save() pour un objet EmbeddedDocument. - pass + article1.save() sorted(articles, key=lambda t: t.date, reverse=True) feed1 = Feed(title=feed["feed_title"], link=feed["feed_link"], 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 + feed1.save()
\ No newline at end of file diff --git a/pyaggr3g470r/templates/articles.html b/pyaggr3g470r/templates/articles.html index 20dd0e7f..3737b24e 100644 --- a/pyaggr3g470r/templates/articles.html +++ b/pyaggr3g470r/templates/articles.html @@ -16,17 +16,17 @@ {% if feed.articles|length % 3 !=0 %} <div class="row"> <div class="col-xs-6 col-sm-4 col-md-4"> - {% if feed.articles[feed.articles|length-1].readed %}<h3>{% else %}<h1>{% endif %} - <a href="/article/{{ feed.articles[feed.articles|length-1].id }}">{{ feed.articles[feed.articles|length-1].title }}</a><h2> - {% if feed.articles[feed.articles|length-1].readed %}</h3>{% else %}</h1>{% endif %} - <h6>{{ feed.articles[feed.articles|length-1].date }}</h6> - </div> - <div class="col-xs-6 col-sm-4 col-md-4"> {% if feed.articles[feed.articles|length-2].readed %}<h3>{% else %}<h1>{% endif %} <a href="/article/{{ feed.articles[feed.articles|length-2].id }}">{{ feed.articles[feed.articles|length-2].title }}</a><h2> {% if feed.articles[feed.articles|length-2].readed %}</h3>{% else %}</h1>{% endif %} <h6>{{ feed.articles[feed.articles|length-2].date }}</h6> </div> + <div class="col-xs-6 col-sm-4 col-md-4"> + {% if feed.articles[feed.articles|length-1].readed %}<h3>{% else %}<h1>{% endif %} + <a href="/article/{{ feed.articles[feed.articles|length-1].id }}">{{ feed.articles[feed.articles|length-1].title }}</a><h2> + {% if feed.articles[feed.articles|length-1].readed %}</h3>{% else %}</h1>{% endif %} + <h6>{{ feed.articles[feed.articles|length-1].date }}</h6> + </div> </div> {% endif %} </div><!-- /.container --> diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 517369fe..f2cfc095 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -18,11 +18,8 @@ mail = Mail() @app.route('/') def home(): #feeds = models.Feed.objects().order_by('title').fields(slice__articles=[0,9]) - #feeds = models.Feed.objects().fields(slice__articles=[0,9]) - feeds = models.Feed.objects() - for feed in feeds: - feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True) - return render_template('home.html', feeds=feeds.fields(slice__articles=[0,9])) + feeds = models.Feed.objects().fields(slice__articles=[0,9]) + return render_template('home.html', feeds=feeds) @app.route('/fetch/', methods=['GET']) def fetch(): |