aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/templates/favorites.html6
-rw-r--r--pyaggr3g470r/views.py10
2 files changed, 7 insertions, 9 deletions
diff --git a/pyaggr3g470r/templates/favorites.html b/pyaggr3g470r/templates/favorites.html
index 9be16692..210f7343 100644
--- a/pyaggr3g470r/templates/favorites.html
+++ b/pyaggr3g470r/templates/favorites.html
@@ -18,7 +18,7 @@
<a href="/edit_feed/{{ feed.id }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
</div>
</div>
- {% for number in range(0, feed.articles.all()|length-(feed.articles.all()|length % 3), 3) %}
+ {% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %}
<div class="row">
{% for n in range(number, number+3) %}
<div class="col-xs-6 col-sm-4 col-md-4">
@@ -30,9 +30,9 @@
{% endfor %}
</div>
{% endfor %}
- {% if feed.articles.all()|length % 3 != 0 %}
+ {% if feed.articles|length % 3 != 0 %}
<div class="row">
- {% for n in range(feed.articles.all()|length-(feed.articles.all()|length % 3), feed.articles.all()|length) %}
+ {% for n in range(feed.articles|length-(feed.articles|length % 3), feed.articles|length) %}
<div class="col-xs-6 col-sm-4 col-md-4">
{% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %}
<a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title|safe }}</a>
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 0212e496..6e8b35d2 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -431,13 +431,11 @@ def favorites():
"""
feeds_with_like = Feed.query.filter(Feed.user_id == g.user.id, Feed.articles.any(like=True))
result, nb_favorites = [], 0
+ light_feed = namedtuple('Feed', ['id', 'title', 'articles'], verbose=False, rename=False)
for feed in feeds_with_like:
- new_feed = feed
- new_feed.articles = Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed.id, Article.like == True).all()
- length = len(new_feed.articles.all())
- if length != 0:
- result.append(new_feed)
- nb_favorites += length
+ articles = Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed.id, Article.like == True).all()
+ result.append(light_feed(feed.id, feed.title, articles))
+ nb_favorites += len(articles)
return render_template('favorites.html', feeds=result, nb_favorites=nb_favorites)
@app.route('/unread/<int:feed_id>', methods=['GET'])
bgstack15