aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-10-02 08:06:03 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-10-02 08:06:03 +0200
commitc45c9e2d78f116c5241676d887df9f1812f218a7 (patch)
tree523eb5d35ed4e06f00b348954e21188b6c030f9b /pyaggr3g470r
parentDo not wait for the complete document is loaded to run the js code. (diff)
downloadnewspipe-c45c9e2d78f116c5241676d887df9f1812f218a7.tar.gz
newspipe-c45c9e2d78f116c5241676d887df9f1812f218a7.tar.bz2
newspipe-c45c9e2d78f116c5241676d887df9f1812f218a7.zip
Bug fix: minor problem on the /search page.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/templates/search.html6
-rw-r--r--pyaggr3g470r/views.py12
2 files changed, 8 insertions, 10 deletions
diff --git a/pyaggr3g470r/templates/search.html b/pyaggr3g470r/templates/search.html
index 7b32d80c..d3a1558d 100644
--- a/pyaggr3g470r/templates/search.html
+++ b/pyaggr3g470r/templates/search.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 cf50dae3..63026f41 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -558,18 +558,16 @@ def search():
search_result, nb_articles = fastsearch.search(user.id, query)
except Exception as e:
flash(gettext('An error occured') + ' (%s).' % e, 'danger')
+ light_feed = namedtuple('Feed', ['id', 'title', 'articles'], verbose=False, rename=False)
for feed_id in search_result:
for feed in user.feeds:
if feed.id == feed_id:
- new_feed = Feed()
- new_feed.id = feed.id
- new_feed.title = feed.title
- new_feed.articles = []
+ articles = []
for article_id in search_result[feed_id]:
current_article = Article.query.filter(Article.user_id == g.user.id, Article.id == article_id).first()
- new_feed.articles.append(current_article)
- new_feed.articles = sorted(new_feed.articles, key=lambda t: t.date, reverse=True)
- result.append(new_feed)
+ articles.append(current_article)
+ articles = sorted(articles, key=lambda t: t.date, reverse=True)
+ result.append(light_feed(feed.id, feed.title, articles))
break
return render_template('search.html', feeds=result, nb_articles=nb_articles, query=query)
bgstack15