aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-04-16 14:24:48 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-04-16 14:24:48 +0200
commitedcfb221ecfec95ea824675863c5d76a45a585bd (patch)
tree3b60ee144d416c06b5f088e7efb31bf72b4f10d5 /pyaggr3g470r
parentremoving unused template (diff)
downloadnewspipe-edcfb221ecfec95ea824675863c5d76a45a585bd.tar.gz
newspipe-edcfb221ecfec95ea824675863c5d76a45a585bd.tar.bz2
newspipe-edcfb221ecfec95ea824675863c5d76a45a585bd.zip
redoing sorting on SQL and allowing to reverse sorting
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/templates/home.html4
-rw-r--r--pyaggr3g470r/views/views.py13
2 files changed, 10 insertions, 7 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index 461b6928..10ad82cb 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -73,9 +73,9 @@
<thead>
<tr>
<th></th>
- <th><a href="{{ gen_url(sort_='feed') }}">{{ _('Feed') }}</a></th>
+ <th><a href="{{ gen_url(sort_='-feed' if sort_ == 'feed' else 'feed') }}">{{ _('Feed') }}</a></th>
<th>{{ _('Article') }}</th>
- <th><a href="{{ gen_url(sort_='date') }}">{{ _('Date') }}</a></th>
+ <th><a href="{{ gen_url(sort_='-date' if sort_ == 'date' else 'date') }}">{{ _('Date') }}</a></th>
</tr>
</thead>
<tbody>
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index c681a94d..c905c6e5 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -258,7 +258,13 @@ def render_home(filters={}, head_title='', page_to_render='home', **kwargs):
head_title = "%s%s" % (feed_contr.get(id=feed_id).title,
(' - %s' % head_title) if head_title else '')
- articles = arti_contr.read(**filters).order_by(Article.date.desc())
+ sort_param = {"feed": Article.title.desc(),
+ "date": Article.date.desc(),
+ "-feed": Article.title.asc(),
+ "-date": Article.date.asc(),
+ }.get(sort_, Article.date.desc())
+
+ articles = arti_contr.read(**filters).order_by(sort_param)
if limit != 'all':
limit = int(limit)
articles = articles.limit(limit)
@@ -277,13 +283,10 @@ def render_home(filters={}, head_title='', page_to_render='home', **kwargs):
and filter_ != 'all' and not articles:
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,
- head_title=head_title, **kwargs)
+ head_title=head_title, sort_=sort_, **kwargs)
@app.route('/')
bgstack15