diff --git a/app/filters.py b/app/filters.py deleted file mode 100644 index a73a454..0000000 --- a/app/filters.py +++ /dev/null @@ -1,7 +0,0 @@ -from app import app -__author__ = 'feliciaan' - -@app.template_filter('euro') -def euro(value): - result = '€' + str(value/100) - return result \ No newline at end of file diff --git a/app/foodbot.py b/app/foodbot.py index 4335503..f723257 100644 --- a/app/foodbot.py +++ b/app/foodbot.py @@ -10,8 +10,8 @@ from app import app, db from admin import admin from login import login_manager from models import * -from filters import * +from utils import * from views import * if __name__ == '__main__': - app.run(debug=True) + app.run() diff --git a/app/templates/errors/401.html b/app/templates/errors/401.html new file mode 100644 index 0000000..b8cb43e --- /dev/null +++ b/app/templates/errors/401.html @@ -0,0 +1,9 @@ +{% extends "layout.html" -%} + +{% block content %} +
+

Unauthorized

+

You're not authorized to look to this page!

+

Go somewhere nice

+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/errors/404.html b/app/templates/errors/404.html new file mode 100644 index 0000000..2a1e549 --- /dev/null +++ b/app/templates/errors/404.html @@ -0,0 +1,9 @@ +{% extends "layout.html" -%} + +{% block content %} +
+

Page Not Found

+

What you were looking for is just not there.

+

Go somewhere nice

+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/layout.html b/app/templates/layout.html index f402dd9..be3a550 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -3,7 +3,7 @@ ('about', 'About'), ('stats', 'Stats'), ] -%} -{% if current_user.is_admin() -%} +{% if not current_user.is_anonymous() and current_user.is_admin() -%} {% set navbar = navbar + [('admin.index', 'Admin')] -%} {% endif -%} {% set active_page = active_page|default('index') -%} diff --git a/app/utils.py b/app/utils.py new file mode 100644 index 0000000..60150bf --- /dev/null +++ b/app/utils.py @@ -0,0 +1,17 @@ +from flask import render_template + +from app import app +__author__ = 'feliciaan' + +@app.template_filter('euro') +def euro(value): + result = '€' + str(value/100) + return result + +@app.errorhandler(404) +def handle404(e): + return render_template('errors/404.html'), 404 + +@app.errorhandler(401) +def handle401(e): + return render_template('errors/401.html'), 401 \ No newline at end of file diff --git a/app/views.py b/app/views.py index 81bdc6d..6bf3794 100644 --- a/app/views.py +++ b/app/views.py @@ -1,5 +1,5 @@ from flask import url_for, render_template, abort -from flask.ext.login import current_user +from flask.ext.login import current_user, login_required from datetime import datetime from app import app @@ -21,11 +21,13 @@ def about(): @app.route('/stats/') +@login_required def stats(): return render_template('stats.html') @app.route('/order/') +@login_required def order(id): order = Order.query.filter(Order.id == id).first() if order is not None: @@ -34,6 +36,7 @@ def order(id): if app.debug: # add route information @app.route('/routes') + @login_required def list_routes(): import urllib output = [] diff --git a/app/zeus.py b/app/zeus.py index 3a65c0e..ee1422e 100644 --- a/app/zeus.py +++ b/app/zeus.py @@ -60,7 +60,7 @@ def get_zeus_oauth_token(): def login_and_redirect_user(user): login_user(user) - return redirect(url_for("index")) + return redirect(url_for("home")) def create_user(username):