diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-04-13 10:10:44 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-04-13 10:10:44 +0200 |
commit | 487b5446d28f1706025d5379bf8c1b384ff3b783 (patch) | |
tree | af61f8f1465d16cb95f5a45eee613cdd1e10d52e /pyaggr3g470r | |
parent | Updated README. (diff) | |
download | newspipe-487b5446d28f1706025d5379bf8c1b384ff3b783.tar.gz newspipe-487b5446d28f1706025d5379bf8c1b384ff3b783.tar.bz2 newspipe-487b5446d28f1706025d5379bf8c1b384ff3b783.zip |
Improvement for the /articles page.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/templates/articles.html | 2 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/pyaggr3g470r/templates/articles.html b/pyaggr3g470r/templates/articles.html index e50b12ec..d2da6d18 100644 --- a/pyaggr3g470r/templates/articles.html +++ b/pyaggr3g470r/templates/articles.html @@ -5,7 +5,7 @@ <h2><a href="{{ feed.site_link }}">{{ feed.title|safe }}</a></h2> <a href="/feed/{{ feed.id }}"><i class="glyphicon glyphicon-info-sign" title="Details"></i></a> <a href="/edit_feed/{{ feed.id }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a> - {% if nb_articles == -1 %} + {% if nb_articles == 10**9 %} <h3>{{ feed.articles.all()|count }} articles.</h3> {% else %} <h3>Last {{ feed.articles.all()|count }} articles. See <a href="/articles/{{ feed.id }}">all articles</a>.</h3> diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 41762d74..423bb55e 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -317,11 +317,16 @@ def articles(feed_id=None, nb_articles=-1): The administrator of the platform is able to access to this view for every users. """ feed = Feed.query.filter(Feed.id == feed_id).first() + new_feed = Feed() + new_feed.id = feed.id + new_feed.title = feed.title if len(feed.articles.all()) <= nb_articles: nb_articles = -1 - if nb_articles != -1: - feed.articles = feed.articles[0:nb_articles] - return render_template('articles.html', feed=feed, nb_articles=nb_articles) + if nb_articles == -1: + nb_articles = int(1e9) + new_feed.articles = Article.query.filter(Article.user_id == g.user.id, \ + Article.feed_id == feed.id).order_by(desc("Article.date")).limit(nb_articles) + return render_template('articles.html', feed=new_feed, nb_articles=nb_articles) @app.route('/favorites/', methods=['GET']) @login_required |