Fix and improve "ordered items" page

This commit is contained in:
Midgard 2020-01-27 03:01:49 +01:00
parent 6f24b52855
commit 8ed38f178c
Signed by: midgard
GPG key ID: 511C112F1331BBB4
4 changed files with 41 additions and 21 deletions

View file

@ -171,6 +171,8 @@ def add_template_filters(app: Flask) -> None:
"A function which converts a value to its euro_string"
return euro_string(value)
app.template_filter("any")(any)
# For usage when you directly call the script with python
if __name__ == "__main__":

View file

@ -64,8 +64,7 @@ class Order(db.Model):
for item in self.items:
dish = group.get(item.dish_name, dict())
dish["count"] = dish.get("count", 0) + 1
if item.comment:
dish["comments"] = dish.get("comments", []) + [item.comment]
dish["comments"] = dish.get("comments", []) + [item.comment]
group[item.dish_name] = dish
return group

View file

@ -63,8 +63,30 @@ body {
width: 100%;
}
.product .extras {
padding-left: 20px;
.showcase {
font-size: 16px;
line-height: 1.2;
}
.showcase h1 {
font-size: 150%;
font-weight: bold;
}
.showcase h2 {
font-size: 110%;
font-weight: bold;
margin-bottom: 0;
}
.showcase .quantity {
font-size: 110%;
}
.showcase .comments {
padding-left: 2em;
}
.showcase .comments li {
margin: 0.7em 0 0.3em;
}
.order_row {
@ -90,10 +112,6 @@ body {
}
}
.showcase .product {
font-size: 16px;
}
/* Add clickable box */
div.box:hover {
cursor: hand;

View file

@ -22,21 +22,22 @@ Haldis - Order {{ order.id }}
<div class="row">
<div class="col-sm-6 col-sm-offset-3 darker showcase" id="items-ordered">
<h3 class="text-center">Ordered dishes: {{ order.items.count() }}</h3>
{% for key, value in order.group_by_dish().items() -%}
<div class="product text-center">
<p>
{{ key }}: {{ value["count"] }}
{% if value["extras"] -%}
<div class="extras">
{% for extra in value["extras"] -%}
<div>- {{ extra }}</div>
<h1 class="text-center">Ordered dishes: {{ order.items.count() }}</h1>
{% for key, value in order.group_by_dish().items() -%}
<div class="dish">
<h2><span class="quantity">{{ value["count"] }}</span> × {{ key }}</h2>
{% if value["comments"]|any -%}
<ul class="comments">
{% for comment in value["comments"] -%}
<li>{% if comment %}{{ comment }}
{% else %}<i>No comment</i>
{% endif %}</li>
{% endfor %}
</div>
</ul>
{%- endif %}
</p>
</div>
{%- endfor %}
</p>
</div>
{%- endfor %}
</div>
</div>