diff --git a/app/templates/layout.html b/app/templates/layout.html index 3baedf4..58862c7 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -5,6 +5,7 @@ {% set navbar = [ ('home', 'Home'), ('order_bp.orders', 'Orders'), + ('locations', 'Locations'), ('about', 'About'), ('stats', 'Stats'), ] -%} diff --git a/app/templates/location.html b/app/templates/location.html new file mode 100644 index 0000000..2ac5081 --- /dev/null +++ b/app/templates/location.html @@ -0,0 +1,31 @@ +{% extends "layout.html" %} +{% set active_page = "locations" -%} + +{% import "utils.html" as util %} + +{% block container %} +
+
+

Location: {{ location.name }}

+ : {{ location.address }}
+ : {{ location.telephone }}
+ : {{ location.website }} +
+
+

Products

+ + + + + + {% for prod in location.products -%} + + + + {%- endfor %} + +
NamePrice
{{ prod.name }}{{ prod.price|euro }} +
+
+
+{% endblock %} diff --git a/app/templates/locations.html b/app/templates/locations.html new file mode 100644 index 0000000..874cf36 --- /dev/null +++ b/app/templates/locations.html @@ -0,0 +1,26 @@ +{% extends "layout.html" %} +{% set active_page = "locations" -%} + +{% import "utils.html" as util %} + +{% block container %} +
+
+

Locations

+ + + + + + {% for loc in locations -%} + + + + + {%- endfor %} + +
NameAddress
{{ loc.name }}{{ loc.address }} +
+
+
+{% endblock %} diff --git a/app/views/__init__.py b/app/views/__init__.py index 911b392..2b7b2d1 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -1,11 +1,11 @@ __author__ = 'feliciaan' -from flask import url_for, render_template, abort, redirect, request +from flask import url_for, render_template, abort, redirect, request, abort from flask.ext.login import current_user, login_required from datetime import datetime, timedelta from app import app, db -from models import Order, OrderItem +from models import Order, OrderItem, Location # import views from views.order import get_orders @@ -17,6 +17,19 @@ def home(): return render_template('home.html', orders=get_orders(), recently_closed=recently_closed) +@app.route('/location') +def locations(): + locs = Location.query.order_by('name') + return render_template('locations.html', locations=locs) + + +@app.route('/location/') +def location(id): + loc = Location.query.filter(Location.id==id).first() + if loc is None: + abort(404) + return render_template('location.html', location=loc) + @app.route('/about/') def about(): return render_template('about.html')