diff --git a/streetup/observations/templates/observations/observation_detail.html b/streetup/observations/templates/observations/observation_detail.html index 21eab51..b999dda 100644 --- a/streetup/observations/templates/observations/observation_detail.html +++ b/streetup/observations/templates/observations/observation_detail.html @@ -497,6 +497,27 @@
+ {% if observation.intervention and observation.intervention.status == 'canceled' %} + + {% endif %} + {% if can_take_action and observation.status == 'to_process' %}
diff --git a/streetup/observations/templates/observations/observation_detail_mobile.html b/streetup/observations/templates/observations/observation_detail_mobile.html index 4628427..4f3dfe6 100644 --- a/streetup/observations/templates/observations/observation_detail_mobile.html +++ b/streetup/observations/templates/observations/observation_detail_mobile.html @@ -79,6 +79,27 @@
+ {% if observation.intervention and observation.intervention.status == 'canceled' %} + + {% endif %} + {% if observation.status == 'to_process' %} {% if can_take_action %} diff --git a/streetup/observations/tests.py b/streetup/observations/tests.py index 9117307..9c77fff 100644 --- a/streetup/observations/tests.py +++ b/streetup/observations/tests.py @@ -473,3 +473,32 @@ class ObservationPermissionTests(TestCase): self.assertEqual(docs.count(), 1) doc = docs.first() self.assertEqual(doc.uploaded_by, self.internal_user) + + def test_canceled_intervention_alert_on_observation_detail(self): + from interventions.models import Intervention + intervention = Intervention.objects.create( + code="INT-TEST-CANCEL", + title="Canceled intervention test", + status="canceled", + cancellation_type="duplicate", + thematic=self.thematic_a, + lat=50.5, + lon=4.5, + ) + obs = Observation.objects.create( + description="Observation with canceled intervention", + latitude=50.5, + longitude=4.5, + created_by=self.internal_user, + thematic=self.thematic_a, + status="to_process", + intervention=intervention, + ) + + self.client.login(username="admin", password="pass") + detail_url = reverse("observations:observation_detail", args=[obs.id]) + response = self.client.get(detail_url) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "Une intervention liée à cette observation a été annulée") + self.assertContains(response, "INT-TEST-CANCEL") + diff --git a/streetup/observations/views.py b/streetup/observations/views.py index 93ae179..d3adbc2 100644 --- a/streetup/observations/views.py +++ b/streetup/observations/views.py @@ -655,7 +655,7 @@ def observations_export_excel(request): @login_required -@observation_object_permission_required() +@observation_object_permission_required(select_related=('thematic', 'category', 'created_by', 'intervention', 'project')) def observation_detail(request, observation_id): """Detail page for a specific observation (desktop and mobile compatible).""" observation = request.observation_obj