Count and display total # of orders
This commit is contained in:
parent
f9b48969b2
commit
2e3ef91ec3
2 changed files with 7 additions and 1 deletions
|
@ -110,6 +110,12 @@ class Order(db.Model):
|
||||||
|
|
||||||
return group
|
return group
|
||||||
|
|
||||||
|
def len(self):
|
||||||
|
size = 0
|
||||||
|
for _ in self.items:
|
||||||
|
size = size + 1
|
||||||
|
return size
|
||||||
|
|
||||||
def group_by_product(self):
|
def group_by_product(self):
|
||||||
group = dict()
|
group = dict()
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-push-2 col-md-4 darker" id="items-ordered">
|
<div class="col-md-push-2 col-md-4 darker" id="items-ordered">
|
||||||
<h3>Ordered products: {% len(order.items) %}</h3>
|
<h3>Ordered products: {{ order.len() }}</h3>
|
||||||
{% for key, value in order.group_by_product().items() -%}
|
{% for key, value in order.group_by_product().items() -%}
|
||||||
<div class="product">
|
<div class="product">
|
||||||
{{ key }}: {{ value["count"] }}
|
{{ key }}: {{ value["count"] }}
|
||||||
|
|
Loading…
Reference in a new issue