Show prices for locations

For @procrat
This commit is contained in:
Feliciaan De Palmenaer 2016-08-01 23:40:04 +02:00
parent 6eeb7e8018
commit ce0fe33c0e
4 changed files with 73 additions and 2 deletions

View file

@ -5,6 +5,7 @@
{% set navbar = [ {% set navbar = [
('home', 'Home'), ('home', 'Home'),
('order_bp.orders', 'Orders'), ('order_bp.orders', 'Orders'),
('locations', 'Locations'),
('about', 'About'), ('about', 'About'),
('stats', 'Stats'), ('stats', 'Stats'),
] -%} ] -%}

View file

@ -0,0 +1,31 @@
{% extends "layout.html" %}
{% set active_page = "locations" -%}
{% import "utils.html" as util %}
{% block container %}
<div class="row" xmlns="http://www.w3.org/1999/html">
<div class="col-md-push-1 col-md-10 darker">
<h3>Location: {{ location.name }}</h3>
<span class="glyphicon glyphicon-home"></span>: {{ location.address }} <br/>
<span class="glyphicon glyphicon-phone"></span>: {{ location.telephone }} <br/>
<span class="glyphicon glyphicon-link"></span>: <a href="{{ location.website}}">{{ location.website }}</a>
</div>
<div class="col-md-push-1 col-md-10 darker">
<h3 id="order-title">Products</h3>
<table class="table table-hover table-condensed">
<thead>
<tr><th>Name</th><th>Price</th></tr>
</thead>
<tbody>
{% for prod in location.products -%}
<tr>
<td>{{ prod.name }}</td>
<td>{{ prod.price|euro }}<td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,26 @@
{% extends "layout.html" %}
{% set active_page = "locations" -%}
{% import "utils.html" as util %}
{% block container %}
<div class="row">
<div class="col-md-push-1 col-md-10 darker">
<h3>Locations</h3>
<table class="table table-hover table-condensed">
<thead>
<tr><th>Name</th><th>Address</th><th></th></tr>
</thead>
<tbody>
{% for loc in locations -%}
<tr>
<td><a href="{{ url_for('location', id=loc.id) }}">{{ loc.name }}</a></td>
<td>{{ loc.address }}<td>
<td><a href="{{ loc.website}}"><span class="glyphicon glyphicon-link"></span></a></td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

View file

@ -1,11 +1,11 @@
__author__ = 'feliciaan' __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 flask.ext.login import current_user, login_required
from datetime import datetime, timedelta from datetime import datetime, timedelta
from app import app, db from app import app, db
from models import Order, OrderItem from models import Order, OrderItem, Location
# import views # import views
from views.order import get_orders from views.order import get_orders
@ -17,6 +17,19 @@ def home():
return render_template('home.html', orders=get_orders(), recently_closed=recently_closed) 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/<int:id>')
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/') @app.route('/about/')
def about(): def about():
return render_template('about.html') return render_template('about.html')