From 7e47793ae2c1766e7075d526a0569fdd553bbda0 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Fri, 8 Mar 2024 09:30:51 +0100 Subject: [PATCH] [#2183] Fixed regression with optional status --- src/open_inwoner/openzaak/notifications.py | 5 +++- .../openzaak/tests/test_notification_utils.py | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/open_inwoner/openzaak/notifications.py b/src/open_inwoner/openzaak/notifications.py index a5ecd0d775..1271ba5fc4 100644 --- a/src/open_inwoner/openzaak/notifications.py +++ b/src/open_inwoner/openzaak/notifications.py @@ -583,11 +583,14 @@ def send_case_update_email( context = { "identification": case.identification, "type_description": case.zaaktype.omschrijving, - "status_description": translate_single_status(status.statustype.omschrijving), "start_date": case.startdatum, "end_date": date.today() + timedelta(days=config.action_required_deadline_days), "case_link": case_detail_url, } + if status: + context["status_description"] = ( + translate_single_status(status.statustype.omschrijving), + ) if extra_context: context.update(extra_context) template.send_email([user.email], context) diff --git a/src/open_inwoner/openzaak/tests/test_notification_utils.py b/src/open_inwoner/openzaak/tests/test_notification_utils.py index 34faef695d..ccb2f4279a 100644 --- a/src/open_inwoner/openzaak/tests/test_notification_utils.py +++ b/src/open_inwoner/openzaak/tests/test_notification_utils.py @@ -70,6 +70,30 @@ def test_send_case_update_email(self): self.assertIn(case_url, body_html) self.assertIn(config.name, body_html) + def test_send_case_update_email__no_status(self): + config = SiteConfiguration.get_solo() + data = MockAPIData() + + user = data.user_initiator + + case = factory(Zaak, data.zaak) + case.zaaktype = factory(ZaakType, data.zaak_type) + + case_url = reverse("cases:case_detail", kwargs={"object_id": str(case.uuid)}) + + send_case_update_email(user, case, "case_document_notification") + + self.assertEqual(len(mail.outbox), 1) + email = mail.outbox[0] + self.assertEqual(email.to, [user.email]) + self.assertIn(config.name, email.subject) + + body_html = email.alternatives[0][0] + self.assertIn(case.identificatie, body_html) + self.assertIn(case.zaaktype.omschrijving, body_html) + self.assertIn(case_url, body_html) + self.assertIn(config.name, body_html) + # TODO we're missing a similar test for get_nnp_initiator_nnp_id_from_roles() def test_get_np_initiator_bsns_from_roles(self): # roles we're interested in