aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-08 22:37:41 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-08 22:37:41 +0200
commit83e10c058a42796fe94bf4a93791bf3883ae51fb (patch)
tree9af541cb79dad16ee21137dba78f2b0cccc2f5e2 /pyaggr3g470r
parent/articles page is working. (diff)
downloadnewspipe-83e10c058a42796fe94bf4a93791bf3883ae51fb.tar.gz
newspipe-83e10c058a42796fe94bf4a93791bf3883ae51fb.tar.bz2
newspipe-83e10c058a42796fe94bf4a93791bf3883ae51fb.zip
/unread and /like views are working.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/templates/favorites.html12
-rw-r--r--pyaggr3g470r/templates/unread.html8
-rw-r--r--pyaggr3g470r/views.py22
3 files changed, 24 insertions, 18 deletions
diff --git a/pyaggr3g470r/templates/favorites.html b/pyaggr3g470r/templates/favorites.html
index c073cfde..50378d3c 100644
--- a/pyaggr3g470r/templates/favorites.html
+++ b/pyaggr3g470r/templates/favorites.html
@@ -13,12 +13,12 @@
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>{{ feed.title|safe }}</h1>
- <a href="/articles/{{ feed.oid }}/100"><i class="glyphicon glyphicon-th-list" title="More articles"></i></a>
- <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="/articles/{{ feed.id }}/100"><i class="glyphicon glyphicon-th-list" title="More articles"></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>
</div>
</div>
- {% 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">
@@ -30,9 +30,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/templates/unread.html b/pyaggr3g470r/templates/unread.html
index 0dc64f66..1a586435 100644
--- a/pyaggr3g470r/templates/unread.html
+++ b/pyaggr3g470r/templates/unread.html
@@ -17,10 +17,10 @@
<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="/mark_as_read/{{ feed.oid }}"><i class="glyphicon glyphicon-check" title="Mark all as read"></i></a>
- <h3>{{ feed.articles|length }} unread articles.</h3>
+ <h3>{{ feed.articles.all()|length }} unread articles.</h3>
</div>
</div>
- {% 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">
@@ -32,9 +32,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 3f05c199..ec330e68 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -316,14 +316,17 @@ def favorites():
"""
List favorites articles.
"""
- user = models.User.objects(email=g.user.email).first()
+ user = User.query.filter(User.id == g.user.id).first()
result = []
nb_favorites = 0
for feed in user.feeds:
- feed.articles = [article for article in feed.articles if article.like]
- length = len(feed.articles)
+ new_feed = Feed()
+ new_feed.id = feed.id
+ new_feed.title = feed.title
+ new_feed.articles = [article for article in feed.articles if article.like]
+ length = len(new_feed.articles.all())
if length != 0:
- result.append(feed)
+ result.append(new_feed)
nb_favorites += length
return render_template('favorites.html', feeds=result, nb_favorites=nb_favorites)
@@ -333,14 +336,17 @@ def unread():
"""
List unread articles.
"""
- user = models.User.objects(email=g.user.email).first()
+ user = User.query.filter(User.id == g.user.id).first()
result = []
nb_unread = 0
for feed in user.feeds:
- feed.articles = [article for article in feed.articles if not article.readed]
- length = len(feed.articles)
+ new_feed = Feed()
+ new_feed.id = feed.id
+ new_feed.title = feed.title
+ new_feed.articles = [article for article in feed.articles if not article.readed]
+ length = len(new_feed.articles.all())
if length != 0:
- result.append(feed)
+ result.append(new_feed)
nb_unread += length
return render_template('unread.html', feeds=result, nb_unread=nb_unread)
bgstack15