Skip to content

Commit

Permalink
Merge pull request #1324 from maykinmedia/task/2640-result-type-descr…
Browse files Browse the repository at this point in the history
…iption

[#2640] Use separate field for storing long case result descriptions
  • Loading branch information
alextreme authored Aug 5, 2024
2 parents 1edaef7 + 292d399 commit 4f5f7d0
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 177 deletions.
14 changes: 13 additions & 1 deletion src/open_inwoner/cms/cases/tests/test_contactform.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,23 @@ def setUp(self):
volgnummer=1,
isEindstatus=True,
)
self.resultaattype_with_naam = generate_oas_component_cached(
"ztc",
"schemas/ResultaatType",
url=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
zaaktype=self.zaaktype["url"],
omschrijving="Short description",
resultaattypeomschrijving="http://example.com",
selectielijstklasse="http://example.com",
naam="Long description (>20 chars) of result",
)
self.result = generate_oas_component_cached(
"zrc",
"schemas/Resultaat",
uuid="a44153aa-ad2c-6a07-be75-15add5113",
url=self.zaak["resultaat"],
resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
# resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
resultaattype=self.resultaattype_with_naam["url"],
zaak=self.zaak["url"],
toelichting="resultaat toelichting",
)
Expand Down Expand Up @@ -260,6 +271,7 @@ def _setUpMocks(self, m):
for resource in [
self.zaak,
self.result,
self.resultaattype_with_naam,
self.zaaktype,
self.status_finish,
self.status_type_finish,
Expand Down
13 changes: 12 additions & 1 deletion src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,22 @@ def setUp(self) -> None:
"geslachtsnaam": "Bazz",
},
)
self.resultaattype_with_naam = generate_oas_component_cached(
"ztc",
"schemas/ResultaatType",
url=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
zaaktype=self.zaaktype["url"],
omschrijving="Short description",
resultaattypeomschrijving="http://example.com",
selectielijstklasse="http://example.com",
naam="Long description (>20 chars) of result",
)
self.result = generate_oas_component_cached(
"zrc",
"schemas/Resultaat",
uuid="a44153aa-ad2c-6a07-be75-15add5113",
url=self.zaak["resultaat"],
resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
resultaattype=self.resultaattype_with_naam["url"],
zaak=self.zaak["url"],
toelichting="resultaat toelichting",
)
Expand Down Expand Up @@ -324,6 +334,7 @@ def _setUpMocks(self, m):

for resource in [
self.zaak,
self.resultaattype_with_naam,
self.result,
self.zaaktype,
self.status_type_new,
Expand Down
24 changes: 20 additions & 4 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ def get_context_data(self, **kwargs):
end_statustype=self.handle_end_statustype(statuses, statustypen),
)
result_data = self.get_result_data(
self.case, self.resulttype_config_mapping, zaken_client
self.case,
self.resulttype_config_mapping,
zaken_client,
catalogi_client,
)

hooks.case_status_seen(self.request.user, self.case)
Expand Down Expand Up @@ -526,15 +529,28 @@ def get_upload_info_context(self, case: Zaak):

@staticmethod
def get_result_data(
case: Zaak, result_type_config_mapping: dict, client: ZakenClient
case: Zaak,
result_type_config_mapping: dict,
zaken_client: ZakenClient,
catalogi_client: CatalogiClient,
) -> dict:
"""
Get display and description for the result of `case`
Note:
For the description, we try the `esuite_compat_naam` attribute of the corresponding
resultaattype first. This is for E-suite compatibility in case the E-suite returns
a description longer than 20 chars. Alternatively, we get the description from the
config of the resultaattype.
"""
if not case.resultaat:
return {}

result = client.fetch_single_result(case.resultaat)
result = zaken_client.fetch_single_result(case.resultaat)
result_type = catalogi_client.fetch_single_resultaat_type(result.resultaattype)

display = result.toelichting
description = getattr(
description = getattr(result_type, "esuite_compat_naam", "") or getattr(
result_type_config_mapping.get(result.resultaattype), "description", ""
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def test_cms_ssd_override_settings(self):

self.assertTrue(benefits_page_is_published())

# import pdbr;pdbr.set_trace()
# check common extension
page = Page.objects.get(publisher_is_draft=False)
extension = page.commonextension
Expand Down
5 changes: 5 additions & 0 deletions src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def process_data(self) -> dict:
result_text = glom_multiple(
self,
(
"resultaat.resultaattype.naam",
"resultaat.resultaattype.omschrijving",
"resultaat.resultaattype.omschrijving_generiek",
"resultaat.resultaattype.resultaattypeomschrijving",
Expand Down Expand Up @@ -230,6 +231,10 @@ class ResultaatType(ZGWModel):
archiefactietermijn: Optional[relativedelta] = None
brondatum_archiefprocedure: Optional[dict] = None

# E-suite compatibility
# result description ("omschrijving") with >20 chars
esuite_compat_naam: str = ""


@dataclass
class Resultaat(ZGWModel):
Expand Down
8 changes: 8 additions & 0 deletions src/open_inwoner/openzaak/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
UserCaseStatusNotification,
ZaakTypeConfig,
ZaakTypeInformatieObjectTypeConfig,
ZaakTypeResultaatTypeConfig,
ZaakTypeStatusTypeConfig,
ZGWApiGroupConfig,
)
Expand Down Expand Up @@ -90,6 +91,13 @@ class Meta:
model = ZaakTypeConfig


class ZaakTypeResultaatTypeConfigFactory(factory.django.DjangoModelFactory):
zaaktype_config = factory.SubFactory(ZaakTypeConfigFactory)

class Meta:
model = ZaakTypeResultaatTypeConfig


class ZaakTypeInformatieObjectTypeConfigFactory(factory.django.DjangoModelFactory):
zaaktype_config = factory.SubFactory(ZaakTypeConfigFactory)
informatieobjecttype_url = factory.Faker("url")
Expand Down
Loading

0 comments on commit 4f5f7d0

Please sign in to comment.