diff --git a/app.py b/app.py index 70ab19f..fbb79f2 100644 --- a/app.py +++ b/app.py @@ -2882,6 +2882,15 @@ def list_products(): if name not in used_suggestion_names ] + usage_counts = dict( + db.session.query( + func.lower(Item.name), + func.coalesce(func.sum(Item.quantity), 0) + ) + .group_by(func.lower(Item.name)) + .all() + ) + query_string = urlencode({k: v for k, v in request.args.items() if k != "page"}) return render_template( @@ -2894,7 +2903,8 @@ def list_products(): per_page=per_page, total_pages=total_pages, query_string=query_string, - total_items=total_items + total_items=total_items, + usage_counts=usage_counts ) diff --git a/templates/admin/list_products.html b/templates/admin/list_products.html index 6769b6c..93dfce7 100644 --- a/templates/admin/list_products.html +++ b/templates/admin/list_products.html @@ -20,6 +20,7 @@ ID Nazwa Dodany przez + Ilość użyć Akcja @@ -35,6 +36,7 @@ - {% endif %} + {{ usage_counts.get(item.name.lower(), 0) }} {% set suggestion = suggestions_dict.get(item.name.lower()) %} {% if suggestion %}