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): def __getattr__(self, name):
if name == "location": if name == "location":
location = first(filter(lambda l: l.id == self.location_id, location_definitions)) return first(filter(lambda l: l.id == self.location_id, location_definitions))
if location:
return location
raise AttributeError() raise AttributeError()
def __repr__(self) -> str: def __repr__(self) -> str:

View file

@ -25,7 +25,11 @@
</form> </form>
{% endif %} {% endif %}
<br/> <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 %} {% if order.location.telephone != None %}
telephone: <a href="tel://{{ order.location.telephone }}">{{ order.location.telephone }}</a><br/> telephone: <a href="tel://{{ order.location.telephone }}">{{ order.location.telephone }}</a><br/>
{% endif %} {% endif %}

View file

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

View file

@ -57,6 +57,7 @@ def order_from_id(order_id: int, form: OrderForm = None) -> str:
if form is None: if form is None:
form = AnonOrderItemForm() if current_user.is_anonymous() \ form = AnonOrderItemForm() if current_user.is_anonymous() \
else OrderItemForm() else OrderItemForm()
if order.location:
form.populate(order.location) form.populate(order.location)
if order.is_closed(): if order.is_closed():
form = None form = None