Skip to content

Commit

Permalink
Merge pull request #1139 from maykinmedia/issue/2207-avoid-duplicate-…
Browse files Browse the repository at this point in the history
…statusses

[#2207] Avoid showing the current status of the case twice in the situation where the zaak.status URL isn't in the status history
  • Loading branch information
alextreme authored Apr 12, 2024
2 parents e015a67 + 09bdc1a commit f91a428
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 102 deletions.
10 changes: 8 additions & 2 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,18 @@ def sync_statuses_with_status_types(

# eSuite compatibility
if isinstance(self.case.status, str):
# OIP requests cases, user goes to detailview of case
# OIP requests the statusses of the case (the status history)
# OIP sees a zaak.status URL which doesn't occur in the status history, however requires this status to determine the statustype and configuration options related to this statustype (Taiga #2037, uploading documents was activated for statustype in the admin but wasn't active for users
# Workaround: OIP requests the current zaak.status individually and adds the retrieved information to the statustype mapping

logger.info(
"Issue #2037 -- Retrieving status individually because of eSuite"
"Issue #2037 -- Retrieving status individually for case {} because of eSuite".format(
self.case.identification
)
)
self.case.status = zaken_client.fetch_single_status(self.case.status)
status_types_mapping[self.case.status.statustype].append(self.case.status)
statuses.append(self.case.status)

catalogi_client = build_client_openzaak("catalogi")
if catalogi_client is None:
Expand Down
100 changes: 0 additions & 100 deletions src/open_inwoner/openzaak/tests/test_case_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,106 +1175,6 @@ def test_document_ordering_by_name(self, m):
self.assertEqual(documents[1].name, self.informatie_object["titel"])
self.assertEqual(documents[2].name, self.informatie_object_no_date["titel"])

@patch(
"open_inwoner.openzaak.clients.ZakenClient.fetch_status_history", autospec=True
)
def test_e_suite_missing_current_status_fetch_status(
self, m, mock_fetch_status_history
):
"""
Regression test for #2037
eSuite can fail to return the status of the current case as part of status
history, which causes the upload button to be hidden. Check that the status
is fetched if it's missing from the eSuite response.
"""
self.maxDiff = None
self._setUpMocks(m)

# e-suite returns nothing, hence status history list is empty
mock_fetch_status_history.return_value = []
m.get(
f"{ZAKEN_ROOT}statussen/29ag1264-c4he-249j-bc24-jip862tle833",
json=self.status_finish,
)

status_new_obj, status_finish_obj = factory(
Status, [self.status_new, self.status_finish]
)
status_new_obj.statustype = factory(StatusType, self.status_type_new)
status_finish_obj.statustype = factory(StatusType, self.status_type_finish)

response = self.app.get(self.case_detail_url, user=self.user)

self.assertEqual(
response.context.get("case")["statuses"],
[
{
"date": datetime.datetime(2021, 3, 12, 0, 0),
"label": "Finish",
"status_indicator": None,
"status_indicator_text": None,
"call_to_action_url": None,
"call_to_action_text": None,
"description": None,
"case_link_text": "Bekijk aanvraag",
}
],
)

@patch(
"open_inwoner.openzaak.clients.ZakenClient.fetch_status_history", autospec=True
)
def test_e_suite_missing_current_status_upload_button_displayed(
self, m, mock_fetch_status_history
):
"""
Regression test for #2037
eSuite can fail to return the status of the current case as part of status
history, which causes the upload button to be hidden. Check that the upload
button is displayed.
"""
self.maxDiff = None
self._setUpMocks(m)

# e-suite returns nothing, hence status history list is empty
mock_fetch_status_history.return_value = []
m.get(
f"{ZAKEN_ROOT}statussen/29ag1264-c4he-249j-bc24-jip862tle833",
json=self.status_finish,
)

zaak_type_config = ZaakTypeConfigFactory(
catalogus__url=f"{CATALOGI_ROOT}catalogussen/1b643db-81bb-d71bd5a2317a",
identificatie=self.zaaktype["identificatie"],
)
zaak_type_iotc = ZaakTypeInformatieObjectTypeConfigFactory(
zaaktype_config=zaak_type_config,
informatieobjecttype_url=self.informatie_object["url"],
zaaktype_uuids=[self.zaaktype["uuid"]],
document_upload_enabled=True,
)
zt_statustype_config = ZaakTypeStatusTypeConfigFactory(
zaaktype_config=zaak_type_config,
statustype_url=self.status_type_finish["url"],
zaaktype_uuids=[self.zaaktype["uuid"]],
document_upload_description="- Foo\n- bar",
)
response = self.app.get(
reverse(
"cases:case_detail_content",
kwargs={"object_id": self.zaak["uuid"]},
),
user=self.user,
)

doc = PyQuery(response.content)

upload_button = doc.find("#document-upload").find("button")

self.assertEqual(upload_button.text(), "Upload documenten")

@freeze_time("2021-01-12 17:00:00")
def test_new_docs(self, m):
self._setUpMocks(m)
Expand Down

0 comments on commit f91a428

Please sign in to comment.