aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-08 20:00:18 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-08 20:00:18 +0200
commit48dfe7334e4879e5f57fe67e55cdf1f11cbfccc3 (patch)
treec4117ae38795d640017f348c66be1a938d725e5a
parentDelete an article. (diff)
downloadnewspipe-48dfe7334e4879e5f57fe67e55cdf1f11cbfccc3.tar.gz
newspipe-48dfe7334e4879e5f57fe67e55cdf1f11cbfccc3.tar.bz2
newspipe-48dfe7334e4879e5f57fe67e55cdf1f11cbfccc3.zip
/articles page is working.
-rw-r--r--pyaggr3g470r/templates/articles.html16
-rw-r--r--pyaggr3g470r/views.py19
2 files changed, 15 insertions, 20 deletions
diff --git a/pyaggr3g470r/templates/articles.html b/pyaggr3g470r/templates/articles.html
index 97b06f6a..e50b12ec 100644
--- a/pyaggr3g470r/templates/articles.html
+++ b/pyaggr3g470r/templates/articles.html
@@ -3,18 +3,18 @@
<div class="container">
<div class="jumbotron">
<h2><a href="{{ feed.site_link }}">{{ feed.title|safe }}</a></h2>
- <a href="/feed/{{ feed.oid }}"><i class="glyphicon glyphicon-info-sign" title="Details"></i></a>
- <a href="/edit_feed/{{ feed.oid }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a>
+ <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 %}
- <h3>{{ feed.articles|count }} articles.</h3>
+ <h3>{{ feed.articles.all()|count }} articles.</h3>
{% else %}
- <h3>Last {{ feed.articles|count }} articles. See <a href="/articles/{{ feed.oid }}">all articles</a>.</h3>
+ <h3>Last {{ feed.articles.all()|count }} articles. See <a href="/articles/{{ feed.id }}">all articles</a>.</h3>
{% endif %}
</div>
- {% if feed.articles|count == 0 %}
+ {% if feed.articles.all()|count == 0 %}
<h1>No articles.</h1>
{% else %}
- {% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %}
+ {% for number in range(0, feed.articles.all()|length-(feed.articles.all()|length % 3), 3) %}
<div class="row">
{% for n in range(number, number+3) %}
<div class="col-xs-6 col-sm-4 col-md-4">
@@ -26,9 +26,9 @@
{% endfor %}
</div>
{% endfor %}
- {% if feed.articles|length % 3 != 0 %}
+ {% if feed.articles.all()|length % 3 != 0 %}
<div class="row">
- {% for n in range(feed.articles|length-(feed.articles|length % 3), feed.articles|length) %}
+ {% for n in range(feed.articles.all()|length-(feed.articles.all()|length % 3), feed.articles.all()|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 48220bb9..3f05c199 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -299,21 +299,16 @@ def delete(article_id=None):
@app.route('/articles/<feed_id>/<int:nb_articles>', methods=['GET'])
@login_required
def articles(feed_id=None, nb_articles=-1):
- try:
- user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first()
- except:
+ feed = Feed.query.filter(Feed.id == feed_id).first()
+ if feed == None:
flash("No such feed.", "danger")
return redirect(url_for('home'))
- for feed in user.feeds:
- if str(feed.oid) == feed_id:
- if len(feed.articles) <= 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)
else:
- flash("No such feed.", "error")
- return redirect(url_for('home'))
+ 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)
@app.route('/favorites/', methods=['GET'])
@login_required
bgstack15