From b045592c9f93572a3feb08cbfbeb7a928df280e2 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 5 Feb 2014 19:55:31 +0100 Subject: Display last 'n' articles. --- pyaggr3g470r/templates/articles.html | 6 +++++- pyaggr3g470r/templates/home.html | 2 +- pyaggr3g470r/views.py | 9 ++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/templates/articles.html b/pyaggr3g470r/templates/articles.html index eb4701d7..97b06f6a 100644 --- a/pyaggr3g470r/templates/articles.html +++ b/pyaggr3g470r/templates/articles.html @@ -5,7 +5,11 @@

{{ feed.title|safe }}

-

{{ feed.articles|count }} articles.

+ {% if nb_articles == -1 %} +

{{ feed.articles|count }} articles.

+ {% else %} +

Last {{ feed.articles|count }} articles. See all articles.

+ {% endif %} {% if feed.articles|count == 0 %}

No articles.

diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index 25cb5012..9117bce9 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -8,7 +8,7 @@

{{ feed.title|safe }}

- + {% if feed.enabled %} diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index f77b49e2..02495311 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -242,13 +242,16 @@ def delete(article_id=None): flash('Impossible to delete the article.', 'danger') return redirect(url_for('home')) -@app.route('/articles/', methods=['GET']) +@app.route('/articles//', methods=['GET']) +@app.route('/articles//', methods=['GET']) @login_required -def articles(feed_id=None): +def articles(feed_id=None, nb_articles=-1): user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() for feed in user.feeds: if str(feed.oid) == feed_id: - return render_template('articles.html', feed=feed) + if nb_articles != -1: + feed.articles = feed.articles[0:nb_articles] + return render_template('articles.html', feed=feed, nb_articles=nb_articles) @app.route('/favorites/', methods=['GET']) @login_required -- cgit