diff --git a/app/filters.py b/app/filters.py
new file mode 100644
index 0000000..a73a454
--- /dev/null
+++ b/app/filters.py
@@ -0,0 +1,7 @@
+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 0165261..4335503 100644
--- a/app/foodbot.py
+++ b/app/foodbot.py
@@ -10,6 +10,7 @@ from app import app, db
from admin import admin
from login import login_manager
from models import *
+from filters import *
from views import *
if __name__ == '__main__':
diff --git a/app/models.py b/app/models.py
index 2fc7274..86ca9e5 100644
--- a/app/models.py
+++ b/app/models.py
@@ -43,6 +43,8 @@ class Location(db.Model):
address = db.Column(db.String(254))
website = db.Column(db.String(120))
food = db.relationship('Food', backref='location', lazy='dynamic')
+ orders = db.relationship('Order', backref='location', lazy='dynamic')
+
def configure(self, name, address, website):
self.name = name
@@ -85,7 +87,7 @@ class Order(db.Model):
self.stoptime = stoptime
def __repr__(self):
- return 'Order'
+ return 'Order %s' % (self.location.name)
class OrderItem(db.Model):
diff --git a/app/templates/about.html b/app/templates/about.html
index a36d7c4..b412cf7 100644
--- a/app/templates/about.html
+++ b/app/templates/about.html
@@ -1,5 +1,6 @@
-{% extends "layout.html" %}
-
+{% extends "layout.html" -%}
+{% set active_page = "about" -%}
+
{% block content %}
About
This is an About page for FoodBot. Don't I look good? Oh stop, you're making me blush.
diff --git a/app/templates/home.html b/app/templates/home.html
index 91b872c..eefe505 100644
--- a/app/templates/home.html
+++ b/app/templates/home.html
@@ -1,4 +1,5 @@
-{% extends "layout.html" %}
+{% extends "layout.html" -%}
+{% set active_page = "home" -%}
{% block content %}
Welcome to FoodBot
diff --git a/app/templates/home_loggedin.html b/app/templates/home_loggedin.html
new file mode 100644
index 0000000..26bbc22
--- /dev/null
+++ b/app/templates/home_loggedin.html
@@ -0,0 +1,14 @@
+{% extends "home.html" %}
+{% block content %}
+{{ super() }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/layout.html b/app/templates/layout.html
index 772121c..f402dd9 100644
--- a/app/templates/layout.html
+++ b/app/templates/layout.html
@@ -1,3 +1,12 @@
+{% set navbar = [
+ ('home', 'Home'),
+ ('about', 'About'),
+ ('stats', 'Stats'),
+] -%}
+{% if current_user.is_admin() -%}
+ {% set navbar = navbar + [('admin.index', 'Admin')] -%}
+{% endif -%}
+{% set active_page = active_page|default('index') -%}
@@ -24,9 +33,11 @@
{% if current_user.is_anonymous() %}
diff --git a/app/templates/login.html b/app/templates/login.html
deleted file mode 100644
index a70fb3d..0000000
--- a/app/templates/login.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "layout.html" %}
-
-{% block content %}
-
-
-
Login with Zeus-Account
-
-
-
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/app/templates/order.html b/app/templates/order.html
new file mode 100644
index 0000000..78329cc
--- /dev/null
+++ b/app/templates/order.html
@@ -0,0 +1,16 @@
+{% extends "layout.html" %}
+{% block content %}
+
+
+
Order {{ order.id }}
+ Courrier: {{ order.courrier.username }}
+ Location:
{{ order.location.name }}
+ Starttime: {{ order.starttime }}
+ Stoptime: {{ order.stoptime }}
+
Orders
+ {% for item in order.orders %}
+ {{ item.user.username }} - {{ item.food.name }} - {{ item.food.price|euro }}
+ {% endfor %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/stats.html b/app/templates/stats.html
index 553a0d1..d6ae270 100644
--- a/app/templates/stats.html
+++ b/app/templates/stats.html
@@ -1,5 +1,5 @@
-{% extends "layout.html" %}
-
+{% extends "layout.html" -%}
+{% set active_page = "stats" -%}
{% block content %}
Stats bruh
TOP 4
diff --git a/app/views.py b/app/views.py
index d9401f0..81bdc6d 100644
--- a/app/views.py
+++ b/app/views.py
@@ -1,11 +1,17 @@
-from flask import url_for, render_template
+from flask import url_for, render_template, abort
+from flask.ext.login import current_user
+from datetime import datetime
from app import app
+from models import Order
@app.route('/')
def home():
+ if not current_user.is_anonymous():
+ orders = Order.query.filter(Order.stoptime > datetime.now()).all()
+ return render_template('home_loggedin.html', orders=orders)
return render_template('home.html')
@@ -19,9 +25,16 @@ def stats():
return render_template('stats.html')
+@app.route('/order/')
+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)
+
if app.debug: # add route information
@app.route('/routes')
- def list_routes(self):
+ def list_routes():
import urllib
output = []
for rule in app.url_map.iter_rules():
diff --git a/app/zeus.py b/app/zeus.py
index 7661260..3a65c0e 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("admin.index"))
+ return redirect(url_for("index"))
def create_user(username):