diff --git a/app/models/order.py b/app/models/order.py index 3a5e1ef..a964cf9 100644 --- a/app/models/order.py +++ b/app/models/order.py @@ -22,9 +22,7 @@ class Order(db.Model): def __getattr__(self, name): if name == "location": - location = first(filter(lambda l: l.id == self.location_id, location_definitions)) - if location: - return location + return first(filter(lambda l: l.id == self.location_id, location_definitions)) raise AttributeError() def __repr__(self) -> str: diff --git a/app/templates/order.html b/app/templates/order.html index cfa2828..51a617b 100644 --- a/app/templates/order.html +++ b/app/templates/order.html @@ -25,7 +25,11 @@ {% endif %}
- location: {{ order.location.name }}
+ location: {% if order.location %} + {{ order.location_name }} + {% else %} + {{ order.location_name }} + {% endif %}
{% if order.location.telephone != None %} telephone: {{ order.location.telephone }}
{% endif %} diff --git a/app/templates/utils.html b/app/templates/utils.html index 6288112..7c62e4b 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -1,7 +1,7 @@ {% macro render_order(order) -%}
-
{{ order.location.name }}
+
{{ order.location_name }}
{{ order.items.count() }} orders

{% if order.stoptime %} diff --git a/app/views/order.py b/app/views/order.py index 8d8f263..2bff4c5 100644 --- a/app/views/order.py +++ b/app/views/order.py @@ -57,7 +57,8 @@ def order_from_id(order_id: int, form: OrderForm = None) -> str: if form is None: form = AnonOrderItemForm() if current_user.is_anonymous() \ else OrderItemForm() - form.populate(order.location) + if order.location: + form.populate(order.location) if order.is_closed(): form = None total_price = sum([o.price for o in order.items])