Skip to content

Commit

Permalink
[#2217] Use 'statustekst' as default case status label
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Mar 25, 2024
1 parent f29e0af commit 8ee20da
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 33 deletions.
14 changes: 10 additions & 4 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 6 additions & 2 deletions src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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),
Expand Down
5 changes: 3 additions & 2 deletions src/open_inwoner/openzaak/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions src/open_inwoner/openzaak/tests/test_case_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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):
Expand Down
40 changes: 21 additions & 19 deletions src/open_inwoner/openzaak/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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",
Expand All @@ -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="",
)
Expand All @@ -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="",
)
Expand Down Expand Up @@ -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="",
)
Expand All @@ -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="",
)
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/open_inwoner/openzaak/tests/test_notification_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self):
informeren=True,
volgnummer=1,
omschrijving="initial",
statustekst="",
isEindStatus=False,
)
self.status_type_final = generate_oas_component_cached(
Expand All @@ -83,6 +84,7 @@ def __init__(self):
informeren=True,
volgnummer=2,
omschrijving="final",
statustekst="",
isEindStatus=True,
)
self.zaak = generate_oas_component_cached(
Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/userfeed/hooks/case_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8ee20da

Please sign in to comment.