aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views/views.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-04-13 08:58:42 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-04-13 08:58:42 +0200
commit9715533ac83fe63df7a384cfd74cfad342b588b4 (patch)
treeeb8b4846677fa25c656a883cbcba39d55fb5fbbc /pyaggr3g470r/views/views.py
parentUpdated translations. (diff)
downloadnewspipe-9715533ac83fe63df7a384cfd74cfad342b588b4.tar.gz
newspipe-9715533ac83fe63df7a384cfd74cfad342b588b4.tar.bz2
newspipe-9715533ac83fe63df7a384cfd74cfad342b588b4.zip
It is now possible to sort articles by date (default) or by feed.
Diffstat (limited to 'pyaggr3g470r/views/views.py')
-rw-r--r--pyaggr3g470r/views/views.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index eabf3ebf..1918b1b5 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -251,6 +251,7 @@ def home(favorites=False):
feed_contr.read(error_count__gt=2)}
filter_ = request.args.get('filter_', 'all' if favorites else 'unread')
+ sort_ = request.args.get('sort_', 'date')
feed_id = int(request.args.get('feed', 0))
limit = request.args.get('limit', 1000)
@@ -270,14 +271,17 @@ def home(favorites=False):
limit = int(limit)
articles = articles.limit(limit)
- def gen_url(filter_=filter_, limit=limit, feed=feed_id):
+ def gen_url(filter_=filter_, sort_=sort_, limit=limit, feed=feed_id):
return url_for('favorites' if favorites else 'home',
- filter_=filter_, limit=limit, feed=feed)
+ filter_=filter_, sort_=sort_, limit=limit, feed=feed)
articles = list(articles)
if not articles and not favorites and feed_id:
return redirect(gen_url(filter_='all'))
+ if sort_ == "feed":
+ articles.sort(key=lambda article: article.source.title)
+
return render_template('home.html', gen_url=gen_url, feed_id=feed_id,
filter_=filter_, limit=limit, feeds=feeds,
unread=unread, articles=articles, in_error=in_error,
bgstack15