From ad765fdca1663d665dda418a52197d52fd54d26f Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 8 Apr 2014 09:03:02 +0200 Subject: Improved articles loading for the home page. --- pyaggr3g470r/templates/home.html | 10 +++++----- pyaggr3g470r/views.py | 7 +------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index 8a4e429d..223653c1 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -1,10 +1,10 @@ {% extends "layout.html" %} {% block content %}
- {% if feeds|count == 0 %} + {% if user.feeds.all()|count == 0 %}

You are not subscribed to any feed. Fix this.

{% else %} - {% for feed in feeds|sort(attribute="title") %} + {% for feed in user.feeds|sort(attribute="title") %}

{{ feed.title|safe }}

@@ -17,7 +17,7 @@
- {% for number in range(0, feed.articles.all()|count-(feed.articles.all()|count % 3), 3) %} + {% for number in range(0, feed.articles[0:9]|count-(feed.articles[0:9]|count % 3), 3) %}
{% for n in range(number, number+3) %}
@@ -29,9 +29,9 @@ {% endfor %}
{% endfor %} - {% if feed.articles.all()|count % 3 != 0 %} + {% if feed.articles[0:9]|count % 3 != 0 %}
- {% for n in range(feed.articles.all()|count-(feed.articles.all()|count % 3), feed.articles.all()|count) %} + {% for n in range(feed.articles[0:9]|count-(feed.articles[0:9]|count % 3), feed.articles[0:9]|count) %}
{% if feed.articles[n].readed %}

{% else %}

{% endif %} {{ feed.articles[n].title|safe }} diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index fb1e6429..c2f6b9bf 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -166,12 +166,7 @@ def home(): The home page lists most recent articles of all feeds. """ user = User.query.filter(User.email == g.user.email).first() - feeds = [] - for feed in user.feeds: - feed.articles = feed.articles[:8] - feeds.append(feed) - return render_template('home.html', user=user, feeds=feeds, \ - head_title="nb unread") + return render_template('home.html', user=user, head_title="nb unread") @app.route('/fetch/', methods=['GET']) @app.route('/fetch/', methods=['GET']) -- cgit