From 4f0bcc4eb579b97f27ed7d6f410f24e217237bf9 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Wed, 10 Sep 2014 17:29:59 +0200 Subject: [PATCH] Refactoring to handle not logged in users --- blender-bfct/application/controllers/main.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/blender-bfct/application/controllers/main.py b/blender-bfct/application/controllers/main.py index 7231116..ddf0ab2 100644 --- a/blender-bfct/application/controllers/main.py +++ b/blender-bfct/application/controllers/main.py @@ -13,16 +13,15 @@ from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound # Views @app.route('/') def homepage(): + latest_application = None if current_user.is_authenticated(): applications = Application.query\ .filter_by(blender_id=current_user.id)\ .all() - - latest_application = None - for application in applications: - if application.status != 'rejected': - latest_application = application - break + for application in applications: + if application.status != 'rejected': + latest_application = application + break return render_template('index.html', application=latest_application, title='home')