diff --git a/app_new/interventions/crud.py b/app_new/interventions/crud.py
index 9543aa3..b1f01a9 100644
--- a/app_new/interventions/crud.py
+++ b/app_new/interventions/crud.py
@@ -401,8 +401,9 @@ def create_for_group():
def detail(id):
"""Détail d'une intervention."""
intervention = Intervention.query.get_or_404(id)
+ allowed_workflow_statuses = set(WORKFLOW_STATUS_ORDERS.get(intervention.workflow_type, WORKFLOW_STATUS_ORDERS['corrective'])) | {'refusee', 'annulee', 'reportee'}
transitions = [(key, value['label']) for key, value in INTERVENTION_STATUSES.items()
- if key in INTERVENTION_TRANSITIONS.get(intervention.status, set())]
+ if key in INTERVENTION_TRANSITIONS.get(intervention.status, set()) and key in allowed_workflow_statuses]
history = intervention.status_history.order_by(StatusChange.created_at.desc()).all()
return render_template('interventions/detail.html',
intervention=intervention,
@@ -532,6 +533,10 @@ def change_status(id):
comment = request.form.get('comment', '')
allowed = INTERVENTION_TRANSITIONS.get(old_status, set())
+ workflow_statuses = set(WORKFLOW_STATUS_ORDERS.get(intervention.workflow_type, WORKFLOW_STATUS_ORDERS['corrective'])) | {'refusee', 'annulee', 'reportee'}
+ if new_status not in workflow_statuses:
+ flash(f'Le statut « {new_status} » ne correspond pas au workflow {intervention.workflow_label}.', 'danger')
+ return redirect(url_for('interventions.detail', id=intervention.id))
if new_status != old_status and new_status not in allowed:
flash(f'Transition interdite : {old_status} → {new_status}.', 'danger')
return redirect(url_for('interventions.detail', id=intervention.id))
diff --git a/app_new/interventions/templates/new.html b/app_new/interventions/templates/new.html
index 1dc5542..cf26b86 100644
--- a/app_new/interventions/templates/new.html
+++ b/app_new/interventions/templates/new.html
@@ -66,6 +66,7 @@
+
{% if json_suggestions and json_suggestions.type %}
Suggestion: {{ json_suggestions.type }}