diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-10-13 14:14:27 +0200 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-10-13 14:14:27 +0200 |
commit | 45c22d114ad375bdb36fc697343145ddba469ebf (patch) | |
tree | 03d7aeeb4195a2229539a417e6a373db0bf35c65 /pyaggr3g470r/views.py | |
parent | MongoEngine list slicing. (diff) | |
download | newspipe-45c22d114ad375bdb36fc697343145ddba469ebf.tar.gz newspipe-45c22d114ad375bdb36fc697343145ddba469ebf.tar.bz2 newspipe-45c22d114ad375bdb36fc697343145ddba469ebf.zip |
First implementation of /favorites page.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r-- | pyaggr3g470r/views.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 642609c9..7d5eeb30 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -5,6 +5,8 @@ from flask import render_template, request, flash, session, url_for, redirect from wtforms import TextField, PasswordField, SubmitField, validators from flask.ext.mail import Message, Mail +from collections import defaultdict + #from forms import ContactForm, SignupForm, SigninForm from pyaggr3g470r import app, db @@ -53,5 +55,10 @@ def articles(feed_id=None): @app.route('/favorites/', methods=['GET']) def favorites(): - feed = models.Feed.objects().fields(articles.like=True) - return render_template('favorites.html', feed=feed)
\ No newline at end of file + favorites = defaultdict(list) + for feed in models.Feed.objects(): + for article in feed.articles: + if article.like: + favorites[feed.title].append(article) + + return render_template('favorites.html', favorites=favorites)
\ No newline at end of file |