From 4cf3a57915c94e92170fde6ea99b472839e49ba4 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 27 Oct 2013 11:40:30 +0100 Subject: Sort articles on the main page. --- pyaggr3g470r/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index c5f42921..517369fe 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -18,8 +18,11 @@ 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]) - return render_template('home.html', feeds=feeds) + #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])) @app.route('/fetch/', methods=['GET']) def fetch(): @@ -60,7 +63,6 @@ def delete(article_id=None): def articles(feed_id=None): feed = models.Feed.objects(id=feed_id).first() feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True) - feed.save() return render_template('articles.html', feed=feed) @app.route('/favorites/', methods=['GET']) -- cgit