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() }} +
+
+

Open orders:

+ +
+
+{% 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 @@