Merge pull request #119 from ZeusWPI/feature/add_location_name_to_browser_title

add location name to browser title
This commit is contained in:
Maxime 2019-05-29 18:05:28 +02:00 committed by GitHub
commit 2314ec0e3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 10 deletions

View file

@ -1,9 +1,9 @@
from models import User, Location, Order, OrderItem, Product from sqlalchemy.sql import desc, func
from sqlalchemy.sql import func, desc
from models import Location, Order, OrderItem, Product, User
class FatModel: class FatModel:
@classmethod @classmethod
def all(cls): def all(cls):
return cls.query.all() return cls.query.all()
@ -13,7 +13,8 @@ class FatModel:
return cls.query.count() return cls.query.count()
class FatLocation(Location, FatModel): pass class FatLocation(Location, FatModel):
pass
class FatOrder(Order, FatModel): class FatOrder(Order, FatModel):
@ -30,14 +31,15 @@ class FatOrder(Order, FatModel):
with_entities(Order.id, func.count(OrderItem.user_id).label('total')) 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): class FatProduct(Product, FatModel):
@classmethod @classmethod
def top4(cls): def top4(cls):
top4 = OrderItem.query\ top4 = OrderItem.query\

View file

@ -15,7 +15,10 @@
{% set active_page = active_page|default('index') -%} {% set active_page = active_page|default('index') -%}
{% block title %} {% block title %}
Haldis - {{ active_page|capitalize }} Haldis - {{ active_page|capitalize }}
{% if title %}
- {{ title }}
{% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}

View file

@ -39,7 +39,7 @@ def location(id):
loc = Location.query.filter(Location.id == id).first() loc = Location.query.filter(Location.id == id).first()
if loc is None: if loc is None:
abort(404) abort(404)
return render_template('location.html', location=loc) return render_template('location.html', location=loc, title=loc.name)
@app.route('/about/') @app.route('/about/')