From 49a8d5839df014c2cbd8b238520ee00810ad74c1 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 17 Aug 2026 00:16:06 +0000 Subject: [PATCH] =?UTF-8?q?Corriger=20la=20vue=20=C3=A9quipements=20et=20l?= =?UTF-8?q?es=20quantit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_new/equipments/main.py | 11 ++++++++++- app_new/templates/equipments/index.html | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app_new/equipments/main.py b/app_new/equipments/main.py index 5f2b34e..cfed467 100644 --- a/app_new/equipments/main.py +++ b/app_new/equipments/main.py @@ -118,7 +118,16 @@ def index(): # uniquement lorsque l'utilisateur déplie une famille. for parent in parents: parent.zones_list = [] - parent.individual_count = parent.quantity or 0 + def quantity_total(node, seen=None): + seen = seen or set() + if node.id in seen: + return 0 + seen.add(node.id) + children = list(node.children) + if not children: + return node.quantity or 1 + return sum(quantity_total(child, seen) for child in children if not child.is_deleted) + parent.individual_count = quantity_total(parent) categories = EquipmentCategory.query.order_by(EquipmentCategory.name).all() buildings = Building.query.order_by(Building.name).all() diff --git a/app_new/templates/equipments/index.html b/app_new/templates/equipments/index.html index 9c2c1f5..95cb9c7 100644 --- a/app_new/templates/equipments/index.html +++ b/app_new/templates/equipments/index.html @@ -61,7 +61,7 @@ {% if view == 'zones' %}
Quantités regroupées par zone, salle et type d’équipement.
{% for building in zone_tree %}
{{ building.name }}
-{% for zone in building.zones %}
{{ zone.name }} {{ zone.rooms|length }} salle(s){% for room in zone.rooms %}
{{ room.name }} {{ room.types|sum(attribute='quantity') }}{% for item in room.types %}{% endfor %}
{{ item.name }}{{ item.category }}{{ item.quantity }}
{% endfor %}
{% endfor %}
{% else %}
Aucun équipement localisé.
{% endfor %} +{% for zone in building.zones %}
{{ zone.name }} {{ zone.rooms|length }} salle(s){% for room in zone.rooms %}
{{ room.name }} {{ room.types|sum(attribute='quantity') }}{% for item in room.types %}{% endfor %}
{{ item.name }}{{ item.category }}{{ item.quantity }}
{% endfor %}
{% endfor %}{% else %}
Aucun équipement localisé.
{% endfor %} {% else %} {% if parents %}