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" "A function which converts a value to its euro_string"
return euro_string(value) return euro_string(value)
app.template_filter("any")(any)
# For usage when you directly call the script with python # For usage when you directly call the script with python
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -64,8 +64,7 @@ class Order(db.Model):
for item in self.items: for item in self.items:
dish = group.get(item.dish_name, dict()) dish = group.get(item.dish_name, dict())
dish["count"] = dish.get("count", 0) + 1 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 group[item.dish_name] = dish
return group return group

View file

@ -63,8 +63,30 @@ body {
width: 100%; width: 100%;
} }
.product .extras { .showcase {
padding-left: 20px; 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 { .order_row {
@ -90,10 +112,6 @@ body {
} }
} }
.showcase .product {
font-size: 16px;
}
/* Add clickable box */ /* Add clickable box */
div.box:hover { div.box:hover {
cursor: hand; cursor: hand;

View file

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