Skip to content

Commit

Permalink
Cherry-picking #2171 + #2166
Browse files Browse the repository at this point in the history
  • Loading branch information
alextreme committed Mar 6, 2024
1 parent 42a8b45 commit 9ab0329
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/open_inwoner/openzaak/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
get_zaak_type_info_object_type_config,
is_info_object_visible,
is_zaak_visible,
translate_single_status,
)
from open_inwoner.userfeed import hooks
from open_inwoner.utils.logentry import system_action as log_system_action
Expand Down Expand Up @@ -582,7 +583,7 @@ def send_case_update_email(
context = {
"identification": case.identification,
"type_description": case.zaaktype.omschrijving,
"status_description": status.statustype.omschrijving,
"status_description": translate_single_status(status.statustype.omschrijving),
"start_date": case.startdatum,
"end_date": date.today() + timedelta(days=config.action_required_deadline_days),
"case_link": case_detail_url,
Expand Down
7 changes: 6 additions & 1 deletion src/open_inwoner/openzaak/tests/test_notification_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from open_inwoner.openzaak.tests.factories import generate_rol

from ..api_models import Status, StatusType, Zaak, ZaakType
from ..models import StatusTranslation
from .test_notification_data import MockAPIData


Expand All @@ -38,6 +39,10 @@ def test_send_case_update_email(self):

case.status = status

StatusTranslation.objects.create(
status=status.statustype.omschrijving, translation="My Translated Status"
)

case_url = reverse("cases:case_detail", kwargs={"object_id": str(case.uuid)})

# mock `_format_zaak_identificatie`, but then continue with result of actual call
Expand All @@ -61,7 +66,7 @@ def test_send_case_update_email(self):
body_html = email.alternatives[0][0]
self.assertIn(case.identificatie, body_html)
self.assertIn(case.zaaktype.omschrijving, body_html)
self.assertIn(status.statustype.omschrijving, body_html)
self.assertIn("My Translated Status", body_html)
self.assertIn(case_url, body_html)
self.assertIn(config.name, body_html)

Expand Down
7 changes: 7 additions & 0 deletions src/open_inwoner/openzaak/tests/test_status_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from open_inwoner.openzaak.models import StatusTranslation
from open_inwoner.openzaak.tests.factories import StatusTranslationFactory
from open_inwoner.openzaak.utils import translate_single_status


class StatusTranslationModelTest(TestCase):
Expand All @@ -24,3 +25,9 @@ def test_lookup(self):
self.assertEqual(expected, actual)

# NOTE the TranslationLookup helper is further tested in its own file
# src/open_inwoner/utils/tests/test_translate.py

def test_helper(self):
StatusTranslationFactory(status="foo", translation="FOO")
self.assertEqual("FOO", translate_single_status("foo"))
self.assertEqual("not_translated", translate_single_status("not_translated"))
2 changes: 1 addition & 1 deletion src/open_inwoner/openzaak/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ def translate_single_status(status_text: str) -> str:
status=status_text
)
except StatusTranslation.DoesNotExist:
return ""
return status_text
4 changes: 1 addition & 3 deletions src/open_inwoner/userfeed/hooks/case_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def title(self) -> str:
@property
def message(self) -> str:
status_text = self.get_data("status_omschrijving")
status_text = (
translate_single_status(status_text) or status_text or _("onbekend")
)
status_text = translate_single_status(status_text) or _("onbekend")
html = escape(self.base_message)
status = format_html('<span class="status">{}</span>', status_text)
html = format_html(html, status=status)
Expand Down

0 comments on commit 9ab0329

Please sign in to comment.