From 8ee20da8748717d68ebfc27ab57ca4799660af2d Mon Sep 17 00:00:00 2001 From: Paul Schilling Date: Mon, 18 Mar 2024 17:01:45 +0100 Subject: [PATCH] [#2217] Use 'statustekst' as default case status label --- src/open_inwoner/cms/cases/views/status.py | 14 +++++-- src/open_inwoner/openzaak/api_models.py | 8 +++- src/open_inwoner/openzaak/notifications.py | 5 ++- .../openzaak/tests/test_case_detail.py | 9 ++--- src/open_inwoner/openzaak/tests/test_cases.py | 40 ++++++++++--------- .../openzaak/tests/test_notification_data.py | 2 + .../userfeed/hooks/case_status.py | 3 +- 7 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/open_inwoner/cms/cases/views/status.py b/src/open_inwoner/cms/cases/views/status.py index 31956ef8ea..fd1b9dd6f5 100644 --- a/src/open_inwoner/cms/cases/views/status.py +++ b/src/open_inwoner/cms/cases/views/status.py @@ -369,8 +369,11 @@ def handle_end_statustype_data( end_statustype_data = None if not status_types_mapping.get(end_statustype.url): end_statustype_data = { - "label": status_translate( - end_statustype.omschrijving, default=_("No data available") + "label": ( + end_statustype.statustekst + or status_translate( + end_statustype.omschrijving, default=_("No data available") + ) ), "status_indicator": getattr( self.statustype_config_mapping.get(end_statustype.url), @@ -541,8 +544,11 @@ def get_statuses_data( return [ { "date": s.datum_status_gezet, - "label": lookup.from_glom( - s, "statustype.omschrijving", default=_("No data available") + "label": ( + s.statustype.statustekst + or lookup.from_glom( + s, "statustype.omschrijving", default=_("No data available") + ) ), "status_indicator": getattr( statustype_config_mapping.get(s.statustype.url), diff --git a/src/open_inwoner/openzaak/api_models.py b/src/open_inwoner/openzaak/api_models.py index 377397e201..8a0da498c7 100644 --- a/src/open_inwoner/openzaak/api_models.py +++ b/src/open_inwoner/openzaak/api_models.py @@ -5,6 +5,7 @@ from typing import Optional, Union from dateutil.relativedelta import relativedelta +from glom import glom from zgw_consumers.api_models.base import Model, ZGWModel from zgw_consumers.api_models.constants import RolOmschrijving, RolTypes @@ -79,8 +80,11 @@ def process_data(self) -> dict: "start_date": self.startdatum, "end_date": getattr(self, "einddatum", None), "description": self.zaaktype.omschrijving, - "current_status": status_translate.from_glom( - self, "status.statustype.omschrijving", default="" + "current_status": ( + glom(self, "status.statustype.statustekst") + or status_translate.from_glom( + self, "status.statustype.omschrijving", default="" + ) ), "zaaktype_config": getattr(self, "zaaktype_config", None), "statustype_config": getattr(self, "statustype_config", None), diff --git a/src/open_inwoner/openzaak/notifications.py b/src/open_inwoner/openzaak/notifications.py index 1b8bd7c8c9..fa49a3e637 100644 --- a/src/open_inwoner/openzaak/notifications.py +++ b/src/open_inwoner/openzaak/notifications.py @@ -591,10 +591,11 @@ def send_case_update_email( "case_link": case_detail_url, } if status: - context["status_description"] = translate_single_status( + context[ + "status_description" + ] = status.statustype.statustekst or 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_case_detail.py b/src/open_inwoner/openzaak/tests/test_case_detail.py index 2de97d5ed6..b77df7cf71 100644 --- a/src/open_inwoner/openzaak/tests/test_case_detail.py +++ b/src/open_inwoner/openzaak/tests/test_case_detail.py @@ -219,7 +219,7 @@ def setUp(self): catalogus=f"{CATALOGI_ROOT}catalogussen/1b643db-81bb-d71bd5a2317a", omschrijving="Initial request", omschrijvingGeneriek="some content", - statustekst="", + statustekst="Registered", volgnummer=1, isEindstatus=False, ) @@ -735,7 +735,7 @@ def test_status_is_retrieved_when_user_logged_in_via_digid( "statuses": [ { "date": datetime.datetime(2021, 1, 12), - "label": "Initial request", + "label": "Registered", "status_indicator": "warning", "status_indicator_text": "foo", "call_to_action_url": "", @@ -858,7 +858,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m): "statuses": [ { "date": datetime.datetime(2021, 1, 12), - "label": "Initial request", + "label": "Registered", "status_indicator": "warning", "status_indicator_text": "foo", "call_to_action_url": "", @@ -1384,9 +1384,8 @@ def test_page_translates_statuses(self, m): response = self.app.get( self.case_detail_url, user=self.user, headers={"HX-Request": "true"} ) - self.assertNotContains(response, st1.status) + self.assertNotContains(response, st1.translation) self.assertNotContains(response, st2.status) - self.assertContains(response, st1.translation) self.assertContains(response, st2.translation) def test_when_accessing_case_detail_a_timelinelog_is_created(self, m): diff --git a/src/open_inwoner/openzaak/tests/test_cases.py b/src/open_inwoner/openzaak/tests/test_cases.py index 7e1cf92496..bd2024cb83 100644 --- a/src/open_inwoner/openzaak/tests/test_cases.py +++ b/src/open_inwoner/openzaak/tests/test_cases.py @@ -191,21 +191,23 @@ def setUp(self): vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduidingen.openbaar, indicatieInternOfExtern="intern", ) - self.status_type1 = generate_oas_component_cached( + self.status_type_initial = generate_oas_component_cached( "ztc", "schemas/StatusType", url=f"{CATALOGI_ROOT}statustypen/e3798107-ab27-4c3c-977d-777yu878km09", zaaktype=self.zaaktype["url"], omschrijving="Initial request", + statustekst="", volgnummer=1, isEindstatus=False, ) - self.status_type2 = generate_oas_component_cached( + self.status_type_finish = generate_oas_component_cached( "ztc", "schemas/StatusType", url=f"{CATALOGI_ROOT}statustypen/e3798107-ab27-4c3c-977d-744516671fe4", zaaktype=self.zaaktype["url"], omschrijving="Finish", + statustekst="Statustekst finish", volgnummer=2, isEindstatus=True, ) @@ -220,7 +222,7 @@ def setUp(self): ) self.zt_statustype_config1 = ZaakTypeStatusTypeConfigFactory.create( zaaktype_config=self.zaaktype_config1, - statustype_url=self.status_type1["url"], + statustype_url=self.status_type_initial["url"], status_indicator=StatusIndicators.warning, status_indicator_text="U moet documenten toevoegen", description="Lorem ipsum dolor sit amet", @@ -246,7 +248,7 @@ def setUp(self): "schemas/Status", url=self.zaak1["status"], zaak=self.zaak1["url"], - statustype=self.status_type1["url"], + statustype=self.status_type_initial["url"], datumStatusGezet="2021-01-12", statustoelichting="", ) @@ -268,7 +270,7 @@ def setUp(self): "schemas/Status", url=self.zaak2["status"], zaak=self.zaak2["url"], - statustype=self.status_type1["url"], + statustype=self.status_type_initial["url"], datumStatusGezet="2021-03-12", statustoelichting="", ) @@ -317,7 +319,7 @@ def setUp(self): "schemas/Status", url=self.zaak3["status"], zaak=self.zaak3["url"], - statustype=self.status_type2["url"], + statustype=self.status_type_finish["url"], datumStatusGezet="2021-03-15", statustoelichting="", ) @@ -340,7 +342,7 @@ def setUp(self): "schemas/Status", url=self.zaak_intern["status"], zaak=self.zaak_intern["url"], - statustype=self.status_type1["url"], + statustype=self.status_type_initial["url"], datumStatusGezet="2021-01-12", statustoelichting="", ) @@ -395,8 +397,8 @@ def _setUpMocks(self, m): ) for resource in [ self.zaaktype, - self.status_type1, - self.status_type2, + self.status_type_initial, + self.status_type_finish, self.status1, self.status2, self.status3, @@ -414,7 +416,7 @@ def test_list_cases(self, m): # led to errors when retrieving the ZaakTypeStatusTypeConfig. This duplicate # config is added to verify that that issue was solved ZaakTypeStatusTypeConfigFactory.create( - statustype_url=self.status_type1["url"], + statustype_url=self.status_type_initial["url"], status_indicator=StatusIndicators.warning, status_indicator_text="U moet documenten toevoegen", description="Lorem ipsum dolor sit amet", @@ -434,7 +436,7 @@ def test_list_cases(self, m): "end_date": None, "identification": self.zaak2["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", @@ -445,7 +447,7 @@ def test_list_cases(self, m): "end_date": None, "identification": self.zaak1["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", @@ -456,7 +458,7 @@ def test_list_cases(self, m): "end_date": datetime.date.fromisoformat(self.zaak3["einddatum"]), "identification": self.zaak3["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type2["omschrijving"], + "current_status": self.status_type_finish["statustekst"], "zaaktype_config": self.zaaktype_config1, "statustype_config": None, "case_type": "Zaak", @@ -515,7 +517,7 @@ def test_list_cases_for_eherkenning_user(self, m): "end_date": None, "identification": self.zaak_eherkenning2["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", @@ -528,7 +530,7 @@ def test_list_cases_for_eherkenning_user(self, m): "end_date": None, "identification": self.zaak_eherkenning1["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", @@ -596,7 +598,7 @@ def test_list_cases_for_eherkenning_user_with_vestigingsnummer(self, m): "end_date": None, "identification": self.zaak_eherkenning1["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", @@ -715,7 +717,7 @@ def test_reformat_esuite_zaak_identificatie(self, m): def test_list_cases_translates_status(self, m): st1 = StatusTranslationFactory( - status=self.status_type1["omschrijving"], + status=self.status_type_initial["omschrijving"], translation="Translated Status Type", ) self._setUpMocks(m) @@ -774,7 +776,7 @@ def test_list_cases_paginated(self, m): "end_date": None, "identification": self.zaak2["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", @@ -797,7 +799,7 @@ def test_list_cases_paginated(self, m): "end_date": None, "identification": self.zaak1["identificatie"], "description": self.zaaktype["omschrijving"], - "current_status": self.status_type1["omschrijving"], + "current_status": self.status_type_initial["omschrijving"], "zaaktype_config": self.zaaktype_config1, "statustype_config": self.zt_statustype_config1, "case_type": "Zaak", diff --git a/src/open_inwoner/openzaak/tests/test_notification_data.py b/src/open_inwoner/openzaak/tests/test_notification_data.py index 9d2dbb7452..03e0c6a277 100644 --- a/src/open_inwoner/openzaak/tests/test_notification_data.py +++ b/src/open_inwoner/openzaak/tests/test_notification_data.py @@ -73,6 +73,7 @@ def __init__(self): informeren=True, volgnummer=1, omschrijving="initial", + statustekst="", isEindStatus=False, ) self.status_type_final = generate_oas_component_cached( @@ -83,6 +84,7 @@ def __init__(self): informeren=True, volgnummer=2, omschrijving="final", + statustekst="", isEindStatus=True, ) self.zaak = generate_oas_component_cached( diff --git a/src/open_inwoner/userfeed/hooks/case_status.py b/src/open_inwoner/userfeed/hooks/case_status.py index 9789ca0c21..ec4ad3e769 100644 --- a/src/open_inwoner/userfeed/hooks/case_status.py +++ b/src/open_inwoner/userfeed/hooks/case_status.py @@ -23,7 +23,8 @@ def case_status_notification_received(user: User, case: Zaak, status: Status): "case_uuid": case.uuid, "case_identificatie": case.identificatie, "case_omschrijving": case.omschrijving, - "status_omschrijving": status.statustype.omschrijving, + "status_omschrijving": status.statustype.statustekst + or status.statustype.omschrijving, # new for actionable "catalogus_url": case.zaaktype.catalogus, "case_type_identificatie": case.zaaktype.identificatie,