From 02c9abe28ca2faffb6b9945f5b7a335dc8a783c9 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Wed, 29 May 2019 18:02:55 +0200 Subject: [PATCH] add location name to browser title --- app/fatmodels.py | 18 ++++++++++-------- app/templates/layout.html | 5 ++++- app/views/__init__.py | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/fatmodels.py b/app/fatmodels.py index 9f7673f..8f0b7dc 100644 --- a/app/fatmodels.py +++ b/app/fatmodels.py @@ -1,9 +1,9 @@ -from models import User, Location, Order, OrderItem, Product -from sqlalchemy.sql import func, desc +from sqlalchemy.sql import desc, func + +from models import Location, Order, OrderItem, Product, User class FatModel: - @classmethod def all(cls): return cls.query.all() @@ -13,7 +13,8 @@ class FatModel: return cls.query.count() -class FatLocation(Location, FatModel): pass +class FatLocation(Location, FatModel): + pass class FatOrder(Order, FatModel): @@ -30,14 +31,15 @@ class FatOrder(Order, FatModel): with_entities(Order.id, func.count(OrderItem.user_id).label('total')) -class FatUser(User, FatModel): pass +class FatUser(User, FatModel): + pass -class FatOrderItem(OrderItem, FatModel): pass +class FatOrderItem(OrderItem, FatModel): + pass class FatProduct(Product, FatModel): - @classmethod def top4(cls): top4 = OrderItem.query\ @@ -51,4 +53,4 @@ class FatProduct(Product, FatModel): .order_by(desc('count'))\ .limit(4) for top in top4: - print(top) \ No newline at end of file + print(top) diff --git a/app/templates/layout.html b/app/templates/layout.html index d19fd43..15d5212 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -15,7 +15,10 @@ {% set active_page = active_page|default('index') -%} {% block title %} - Haldis - {{ active_page|capitalize }} +Haldis - {{ active_page|capitalize }} + {% if title %} + - {{ title }} + {% endif %} {% endblock %} {% block styles %} diff --git a/app/views/__init__.py b/app/views/__init__.py index e82b111..dd8c04f 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -39,7 +39,7 @@ def location(id): loc = Location.query.filter(Location.id == id).first() if loc is None: abort(404) - return render_template('location.html', location=loc) + return render_template('location.html', location=loc, title=loc.name) @app.route('/about/')