From 16c5a5ff8822a45c6f21747456a6c7114df850ea Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Aug 2026 22:57:32 +0000 Subject: [PATCH] Corriger l'affichage de l'historique des statuts --- app_new/core/models/maintenance.py | 15 +++++++++++++++ app_new/interventions/templates/detail.html | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app_new/core/models/maintenance.py b/app_new/core/models/maintenance.py index a0c1173..194002c 100644 --- a/app_new/core/models/maintenance.py +++ b/app_new/core/models/maintenance.py @@ -300,6 +300,21 @@ class StatusChange(db.Model): # Relations changed_by = db.relationship("User", backref="status_changes_list") + + @property + def to_label(self): + from app_new.constants import INTERVENTION_STATUSES + return INTERVENTION_STATUSES.get(self.to_status, {}).get("label", self.to_status or "Statut inconnu") + + @property + def from_label(self): + from app_new.constants import INTERVENTION_STATUSES + return INTERVENTION_STATUSES.get(self.from_status, {}).get("label", self.from_status or "Création") + + @property + def to_color(self): + from app_new.constants import INTERVENTION_STATUSES + return INTERVENTION_STATUSES.get(self.to_status, {}).get("color", "secondary") def __repr__(self): return f"" diff --git a/app_new/interventions/templates/detail.html b/app_new/interventions/templates/detail.html index 52ecb45..33354f8 100644 --- a/app_new/interventions/templates/detail.html +++ b/app_new/interventions/templates/detail.html @@ -359,12 +359,10 @@
{{ change.to_label }} - {% if change.from_status %} - (de {{ change.from_label }}) - {% endif %} + (de {{ change.from_label }})
- Par {{ change.changed_by.full_name }} — {{ change.created_at|datetime_fmt if change.created_at else '—' }} + Par {{ change.changed_by.full_name if change.changed_by else 'Utilisateur supprimé' }} — {{ change.created_at|datetime_fmt if change.created_at else '—' }} {% if change.comment %}
{{ change.comment }}