aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-04-07 10:19:58 +0200
committerCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-04-07 10:19:58 +0200
commitc87817488673385b7f9d78020d22788c5f1d9f7d (patch)
treecc1933cd489d6c2432bb679e698dc8b4edf1edd0 /pyaggr3g470r/views
parentReleased version 6.5. (diff)
parentcorrecting the way we use the controllers and adding documentation (diff)
downloadnewspipe-c87817488673385b7f9d78020d22788c5f1d9f7d.tar.gz
newspipe-c87817488673385b7f9d78020d22788c5f1d9f7d.tar.bz2
newspipe-c87817488673385b7f9d78020d22788c5f1d9f7d.zip
Merged in jaesivsm/pyaggr3g470r (pull request #7)
improving http crawler and misc correction on controller use
Diffstat (limited to 'pyaggr3g470r/views')
-rw-r--r--pyaggr3g470r/views/views.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index 3b39e9b0..fd970cba 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -93,7 +93,7 @@ def before_request():
@login_manager.user_loader
def load_user(email):
# Return an instance of the User model
- return controllers.UserController(email).get(email=email)
+ return controllers.UserController().get(email=email)
#
@@ -153,7 +153,7 @@ def login():
form = SigninForm()
if form.validate_on_submit():
- user = controllers.UserController(form.email.data).get(email=form.email.data)
+ user = controllers.UserController().get(email=form.email.data)
login_user(user)
g.user = user
session['email'] = form.email.data
@@ -248,7 +248,7 @@ def home():
.filter(Article.readed == False, Article.user_id == g.user.id)\
.group_by(Article.feed_id).all()
in_error = {feed.id: feed.error_count for feed in
- FeedController(g.user.id).read(error_count__gt=0).all()}
+ FeedController(g.user.id).read(error_count__gt=2).all()}
def gen_url(filter_=filter_, limit=limit, feed=feed_id):
return '?filter_=%s&limit=%s&feed=%d' % (filter_, limit, feed)
return render_template('home.html', gen_url=gen_url, feed_id=feed_id,
@@ -382,7 +382,7 @@ def inactives():
List of inactive feeds.
"""
nb_days = int(request.args.get('nb_days', 365))
- user = controllers.UserController(g.user.email).get(email=g.user.email)
+ user = controllers.UserController(g.user.id).get(email=g.user.email)
today = datetime.datetime.now()
inactives = []
for feed in user.feeds:
@@ -429,7 +429,7 @@ def export_articles():
"""
Export all articles to HTML or JSON.
"""
- user = controllers.UserController(g.user.email).get(id=g.user.id)
+ user = controllers.UserController(g.user.id).get(id=g.user.id)
if request.args.get('format') == "HTML":
# Export to HTML
try:
@@ -439,7 +439,8 @@ def export_articles():
return redirect(redirect_url())
response = make_response(archive_file)
response.headers['Content-Type'] = 'application/x-compressed'
- response.headers['Content-Disposition'] = 'attachment; filename='+archive_file_name
+ response.headers['Content-Disposition'] = 'attachment; filename=%s' \
+ % archive_file_name
elif request.args.get('format') == "JSON":
# Export to JSON
try:
@@ -461,8 +462,9 @@ def export_opml():
"""
Export all feeds to OPML.
"""
- user = controllers.UserController(g.user.email).get(id=g.user.id)
- response = make_response(render_template('opml.xml', user=user, now=datetime.datetime.now()))
+ user = controllers.UserController(g.user.id).get(id=g.user.id)
+ response = make_response(render_template('opml.xml', user=user,
+ now=datetime.datetime.now()))
response.headers['Content-Type'] = 'application/xml'
response.headers['Content-Disposition'] = 'attachment; filename=feeds.opml'
return response
@@ -637,7 +639,7 @@ def profile():
"""
Edit the profile of the currently logged user.
"""
- user = controllers.UserController(g.user.email).get(id=g.user.id)
+ user = controllers.UserController(g.user.id).get(id=g.user.id)
form = ProfileForm()
if request.method == 'POST':
@@ -663,7 +665,7 @@ def delete_account():
"""
Delete the account of the user (with all its data).
"""
- user = controllers.UserController(g.user.email).get(id=g.user.id)
+ user = controllers.UserController(g.user.id).get(id=g.user.id)
if user is not None:
db.session.delete(user)
db.session.commit()
bgstack15