Use order.location_name instead of order.location.name

This commit is contained in:
Midgard 2020-01-27 22:59:07 +01:00
parent 85f36a8fe4
commit 04fb06d187
Signed by: midgard
GPG key ID: 511C112F1331BBB4
4 changed files with 9 additions and 6 deletions

View file

@ -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:

View file

@ -25,7 +25,11 @@
</form>
{% endif %}
<br/>
location: <a href="{{ order.location.website }}">{{ order.location.name }}</a><br/>
location: {% if order.location %}
<a href="{{ url_for('general_bp.location', location_id=order.location_id) }}">{{ order.location_name }}</a>
{% else %}
{{ order.location_name }}
{% endif %}<br/>
{% if order.location.telephone != None %}
telephone: <a href="tel://{{ order.location.telephone }}">{{ order.location.telephone }}</a><br/>
{% endif %}

View file

@ -1,7 +1,7 @@
{% macro render_order(order) -%}
<div class="row darke order_row">
<div class="col-md-8 col-lg-9 order_data">
<h5>{{ order.location.name }}</h5>
<h5>{{ order.location_name }}</h5>
<b class="amount_of_orders">{{ order.items.count() }} orders</b></p>
<p class="time_data">
{% if order.stoptime %}

View file

@ -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])