From baf000eaab28ecd5212db39c3c8a70ae82b6742f Mon Sep 17 00:00:00 2001 From: Sitt Min Oo Date: Thu, 14 Feb 2019 18:45:24 +0100 Subject: [PATCH] edited db models to separate address and tele no. added map for locations --- app/database/add_oceans_garden.py | 2 +- app/database/add_primadonna.py | 4 +- app/database/add_simpizza.py | 2 +- app/models.py | 3 +- app/static/css/map.css | 4 ++ app/templates/layout.html | 1 + app/templates/locations.html | 2 +- app/templates/maps.html | 77 +++++++++++++++++++++++++++++-- app/views/__init__.py | 7 ++- 9 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 app/static/css/map.css diff --git a/app/database/add_oceans_garden.py b/app/database/add_oceans_garden.py index fcc063f..0111ec3 100644 --- a/app/database/add_oceans_garden.py +++ b/app/database/add_oceans_garden.py @@ -18,7 +18,7 @@ specials = ["Nasi Kippenbolletjes Zoetzuur", "Bami Kippenbolletjes Zoetzuur", def add(): chinees = Location() chinees.configure("Oceans's Garden", - "Zwijnaardsesteenweg 399 9000 Gent, tel: 09/222.72.74", + "Zwijnaardsesteenweg 399 9000 Gent", "tel: 09/222.72.74", "http://oceangarden.byethost3.com/studentenmenus.html") db.session.add(chinees) diff --git a/app/database/add_primadonna.py b/app/database/add_primadonna.py index 6b79e11..687db8f 100644 --- a/app/database/add_primadonna.py +++ b/app/database/add_primadonna.py @@ -45,7 +45,7 @@ pizzasTA = { def addTA(): primadonna_takeaway = Location() - primadonna_takeaway.configure("Primadonna (takeaway laten bezorgen)", "Overpoortstraat 46 9000 Gent, tel: 0475 40 13 00", "https://www.takeaway.com/be-en/prima-donna") + primadonna_takeaway.configure("Primadonna (takeaway laten bezorgen)", "Overpoortstraat 46 9000 Gent", "tel: 0475 40 13 00", "https://www.takeaway.com/be-en/prima-donna") db.session.add(primadonna_takeaway) for pizza, price in pizzasTA.items(): @@ -93,7 +93,7 @@ pizzasAfhalen = { def addAfhalen(): primadonna_afhalen = Location() - primadonna_afhalen.configure("Primadonna (bellen en afhalen)", "Overpoortstraat 46 9000 Gent, tel: 0475 40 13 00", "http://primadonnagent.be/Menu.html") + primadonna_afhalen.configure("Primadonna (bellen en afhalen)", "Overpoortstraat 46 9000 Gent", "tel: 0475 40 13 00", "http://primadonnagent.be/Menu.html") db.session.add(primadonna_afhalen) for pizza, price in pizzasAfhalen.items(): diff --git a/app/database/add_simpizza.py b/app/database/add_simpizza.py index 59bfb2e..e3fb7c8 100644 --- a/app/database/add_simpizza.py +++ b/app/database/add_simpizza.py @@ -11,7 +11,7 @@ pizzas = ['Bolognese de luxe', 'Hawaï', 'Popeye', 'Pepperoni', 'Seafood', 'Hot def add(): simpizza = Location() - simpizza.configure("Sim-pizza", "De Pintelaan 252 9000 Gent, tel: 09/321.02.00", "http://simpizza.be") + simpizza.configure("Sim-pizza", "De Pintelaan 252 9000 Gent", "tel: 09/321.02.00", "http://simpizza.be") db.session.add(simpizza) for pizza in pizzas: diff --git a/app/models.py b/app/models.py index 2507e82..9e67f1d 100644 --- a/app/models.py +++ b/app/models.py @@ -50,10 +50,11 @@ class Location(db.Model): products = db.relationship('Product', backref='location', lazy='dynamic') orders = db.relationship('Order', backref='location', lazy='dynamic') - def configure(self, name, address, website): + def configure(self, name, address, telephone, website): self.name = name self.address = address self.website = website + self.telephone = telephone def __repr__(self): return '%s' % (self.name) diff --git a/app/static/css/map.css b/app/static/css/map.css new file mode 100644 index 0000000..eb42ff5 --- /dev/null +++ b/app/static/css/map.css @@ -0,0 +1,4 @@ +#mapid { + min-height: 400px; + height: 600px; +} \ No newline at end of file diff --git a/app/templates/layout.html b/app/templates/layout.html index 58862c7..56ca967 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -6,6 +6,7 @@ ('home', 'Home'), ('order_bp.orders', 'Orders'), ('locations', 'Locations'), + ('map', 'Map'), ('about', 'About'), ('stats', 'Stats'), ] -%} diff --git a/app/templates/locations.html b/app/templates/locations.html index 874cf36..3e78b30 100644 --- a/app/templates/locations.html +++ b/app/templates/locations.html @@ -15,7 +15,7 @@ {% for loc in locations -%} {{ loc.name }} - {{ loc.address }} + {{ loc.address }} {{ loc.telephone }} {%- endfor %} diff --git a/app/templates/maps.html b/app/templates/maps.html index 770d43f..d5fd4b4 100644 --- a/app/templates/maps.html +++ b/app/templates/maps.html @@ -1,18 +1,85 @@ {% extends "layout.html" %} -{% set active_page = "locations" -%} +{% set active_page = "map" -%} {% import "utils.html" as util %} + +{% block container %} +
+{% endblock %} + {% block styles %} {{ super() }} + + {% endblock %} {% block scripts %} {{super()}} - -{% endblock %} + -{% block container %} - + {% endblock %} \ No newline at end of file diff --git a/app/views/__init__.py b/app/views/__init__.py index aaf536b..d9ab307 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -19,9 +19,14 @@ def home(): return render_template('home.html', orders=get_orders(), recently_closed=recently_closed) + +@app.route('/map', defaults= {'id': None}) @app.route('/map/') def map(id): - return render_template('maps.html') + locs = Location.query.order_by('name') + return render_template('maps.html', locations= locs) + + @app.route('/location') def locations(): locs = Location.query.order_by('name')