2015-03-27 18:07:06 +01:00
|
|
|
from flask import url_for, render_template, abort
|
|
|
|
from flask.ext.login import current_user
|
|
|
|
from datetime import datetime
|
2015-03-26 21:49:14 +01:00
|
|
|
|
|
|
|
from app import app
|
2015-03-27 18:07:06 +01:00
|
|
|
from models import Order
|
2015-03-26 22:17:50 +01:00
|
|
|
|
2015-03-26 21:49:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def home():
|
2015-03-27 18:07:06 +01:00
|
|
|
if not current_user.is_anonymous():
|
|
|
|
orders = Order.query.filter(Order.stoptime > datetime.now()).all()
|
|
|
|
return render_template('home_loggedin.html', orders=orders)
|
2015-03-26 21:49:14 +01:00
|
|
|
return render_template('home.html')
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/about/')
|
|
|
|
def about():
|
|
|
|
return render_template('about.html')
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/stats/')
|
|
|
|
def stats():
|
|
|
|
return render_template('stats.html')
|
|
|
|
|
|
|
|
|
2015-03-27 18:07:06 +01:00
|
|
|
@app.route('/order/<int:id>')
|
|
|
|
def order(id):
|
|
|
|
order = Order.query.filter(Order.id == id).first()
|
|
|
|
if order is not None:
|
|
|
|
return render_template('order.html', order=order)
|
|
|
|
return abort(404)
|
|
|
|
|
2015-03-26 21:49:14 +01:00
|
|
|
if app.debug: # add route information
|
|
|
|
@app.route('/routes')
|
2015-03-27 18:07:06 +01:00
|
|
|
def list_routes():
|
2015-03-26 21:49:14 +01:00
|
|
|
import urllib
|
|
|
|
output = []
|
|
|
|
for rule in app.url_map.iter_rules():
|
|
|
|
options = {}
|
|
|
|
for arg in rule.arguments:
|
|
|
|
options[arg] = "[{0}]".format(arg)
|
|
|
|
|
|
|
|
methods = ','.join(rule.methods)
|
|
|
|
url = url_for(rule.endpoint, **options)
|
|
|
|
line = urllib.unquote(
|
|
|
|
"{:50s} {:20s} {}".format(rule.endpoint, methods, url))
|
|
|
|
output.append(line)
|
|
|
|
|
|
|
|
string = ''
|
|
|
|
for line in sorted(output):
|
|
|
|
string += line + "<br/>"
|
|
|
|
|
|
|
|
return string
|