diff options
-rw-r--r-- | pyaggr3g470r/templates/home.html | 4 | ||||
-rw-r--r-- | pyaggr3g470r/views/views.py | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index e055b3e0..98b12e25 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -73,9 +73,9 @@ <thead> <tr> <th></th> - <th>{{ _('Feed') }}</th> + <th><a href="{{ gen_url(sort_='feed') }}">{{ _('Feed') }}</a></th> <th>{{ _('Article') }}</th> - <th>{{ _('Date') }}</th> + <th><a href="{{ gen_url(sort_='date') }}">{{ _('Date') }}</a></th> </tr> </thead> <tbody> 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, |