Look fancy error pages
This commit is contained in:
parent
6e660399a2
commit
d2f9b4dc9d
8 changed files with 43 additions and 12 deletions
|
@ -1,7 +0,0 @@
|
|||
from app import app
|
||||
__author__ = 'feliciaan'
|
||||
|
||||
@app.template_filter('euro')
|
||||
def euro(value):
|
||||
result = '€' + str(value/100)
|
||||
return result
|
|
@ -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()
|
||||
|
|
9
app/templates/errors/401.html
Normal file
9
app/templates/errors/401.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "layout.html" -%}
|
||||
|
||||
{% block content %}
|
||||
<div class="jumbotron">
|
||||
<h1>Unauthorized</h1>
|
||||
<p>You're not authorized to look to this page!</p>
|
||||
<p><a href="{{ url_for('home') }}">Go somewhere nice</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
9
app/templates/errors/404.html
Normal file
9
app/templates/errors/404.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "layout.html" -%}
|
||||
|
||||
{% block content %}
|
||||
<div class="jumbotron">
|
||||
<h1>Page Not Found</h1>
|
||||
<p>What you were looking for is just not there.</p>
|
||||
<p><a href="{{ url_for('home') }}">Go somewhere nice</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -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') -%}
|
||||
|
|
17
app/utils.py
Normal file
17
app/utils.py
Normal file
|
@ -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
|
|
@ -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/<int:id>')
|
||||
@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 = []
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue