aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/views')
-rw-r--r--pyaggr3g470r/views/views.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index dc6bfead..f77bdeba 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -47,6 +47,7 @@ from werkzeug import generate_password_hash
import conf
from pyaggr3g470r import utils, notifications, export
+from pyaggr3g470r import controllers
from pyaggr3g470r.models import User, Feed, Article, Role
from pyaggr3g470r.decorators import feed_access_required
from pyaggr3g470r.forms import SignupForm, SigninForm, AddFeedForm, \
@@ -92,7 +93,7 @@ def before_request():
@login_manager.user_loader
def load_user(email):
# Return an instance of the User model
- return User.query.filter(User.email == email).first()
+ return controllers.UserController(email).get(email=email)
#
@@ -152,7 +153,7 @@ def login():
form = SigninForm()
if form.validate_on_submit():
- user = User.query.filter(User.email == form.email.data).first()
+ user = controllers.UserController(form.email.data).get(email=form.email.data)
login_user(user)
g.user = user
session['email'] = form.email.data
@@ -381,7 +382,7 @@ def inactives():
List of inactive feeds.
"""
nb_days = int(request.args.get('nb_days', 365))
- user = User.query.filter(User.id == g.user.id).first()
+ user = controllers.UserController(g.user.email).get(email=g.user.email)
today = datetime.datetime.now()
inactives = []
for feed in user.feeds:
@@ -428,7 +429,7 @@ def export_articles():
"""
Export all articles to HTML or JSON.
"""
- user = User.query.filter(User.id == g.user.id).first()
+ user = controllers.UserController(g.user.email).get(id=g.user.id)
if request.args.get('format') == "HTML":
# Export to HTML
try:
@@ -460,7 +461,7 @@ def export_opml():
"""
Export all feeds to OPML.
"""
- user = User.query.filter(User.id == g.user.id).first()
+ user = controllers.UserController(g.user.email).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'
@@ -636,7 +637,7 @@ def profile():
"""
Edit the profile of the currently logged user.
"""
- user = User.query.filter(User.email == g.user.email).first()
+ user = controllers.UserController(g.user.email).get(id=g.user.id)
form = ProfileForm()
if request.method == 'POST':
@@ -662,7 +663,7 @@ def delete_account():
"""
Delete the account of the user (with all its data).
"""
- user = User.query.filter(User.email == g.user.email).first()
+ user = controllers.UserController(g.user.email).get(id=g.user.id)
if user is not None:
db.session.delete(user)
db.session.commit()
bgstack15