Skip to content

Commit

Permalink
[#2644] Display related case number in task userfeed
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Aug 5, 2024
1 parent 4f5f7d0 commit 14710c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,4 @@ class OpenTask(Model):
naam: str
startdatum: date
formulier_link: str
zaak_identificatie: str
2 changes: 2 additions & 0 deletions src/open_inwoner/openzaak/tests/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self):
"naam": "Aanvullende informatie gewenst",
"startdatum": "2023-11-14",
"formulierLink": "https://maykinmedia.nl",
"zaakIdentificatie": "6789-2024",
}
self.task2 = {
"url": "https://maykinmedia.nl",
Expand All @@ -53,6 +54,7 @@ def __init__(self):
"naam": "Aanvullende informatie gewenst",
"startdatum": "2023-10-11",
"formulierLink": "https://maykinmedia.nl",
"zaakIdentificatie": "9876-2024",
}

def install_mocks(self, m):
Expand Down
7 changes: 6 additions & 1 deletion src/open_inwoner/userfeed/hooks/external_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@

class OpenTaskFeedItem(FeedItem):
base_title = _("Open task")
extra_title = _("Zaak number")
base_message = _("Open task that is yet to be completed")

@property
def title(self) -> str:
return f"{self.base_title} ({self.get_data('task_identificatie')})"
return (
f"{self.base_title} {self.get_data('task_identificatie')} "
f"({self.extra_title}: {self.get_data('zaak_identificatie')})"
)

@property
def message(self) -> str:
Expand Down Expand Up @@ -53,6 +57,7 @@ def update_external_task_items(user: User, openstaande_taken: list[OpenTask]):
"action_url": task.formulier_link,
"task_name": task.naam,
"task_identificatie": task.identificatie,
"zaak_identificatie": task.zaak_identificatie,
}
if existing_item := existing_uuid_mapping.get(task.uuid):
if existing_item.type_data != type_data:
Expand Down
8 changes: 7 additions & 1 deletion src/open_inwoner/userfeed/tests/test_external_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_userfeed_plugin_render_triggers_update_open_tasks(self):
"task_name": "Aanvullende informatie gewenst",
"task_identificatie": "4321-2023",
"action_url": "https://maykinmedia.nl",
"zaak_identificatie": "6789-2024",
},
)

Expand All @@ -49,7 +50,8 @@ def test_userfeed_plugin_render_triggers_update_open_tasks(self):
# `cms_tools.render_plugin` renders twice
mock.assert_has_calls([call(self.user), call(self.user)])

self.assertIn(f"{_('Open task')} (4321-2023)", html)
self.assertIn(f"{_('Open task')} 4321-2023", html)
self.assertIn(f"({_('Zaak number')}: 6789-2024)", html)
self.assertIn("Aanvullende informatie gewenst", html)

@requests_mock.Mocker()
Expand All @@ -74,6 +76,7 @@ def test_update_user_tasks_create(self, m):
"task_name": "Aanvullende informatie gewenst",
"task_identificatie": "1234-2023",
"action_url": "https://maykinmedia.nl",
"zaak_identificatie": "6789-2024",
},
)
self.assertEqual(
Expand All @@ -89,6 +92,7 @@ def test_update_user_tasks_create(self, m):
"task_name": "Aanvullende informatie gewenst",
"task_identificatie": "4321-2023",
"action_url": "https://maykinmedia.nl",
"zaak_identificatie": "9876-2024",
},
)
self.assertEqual(
Expand All @@ -114,6 +118,7 @@ def test_update_user_tasks_complete_items(self, m):
"task_name": "Aanvullende informatie gewenst",
"task_identificatie": "4321-2023",
"action_url": "https://maykinmedia.nl",
"zaak_identificatie": "9876-2024",
},
)

Expand Down Expand Up @@ -181,5 +186,6 @@ def test_update_user_tasks_update_type_data(self, m):
"task_name": "Aanvullende informatie gewenst",
"task_identificatie": "1234-2023",
"action_url": "https://maykinmedia.nl",
"zaak_identificatie": "6789-2024",
},
)

0 comments on commit 14710c5

Please sign in to comment.