Skip to content

Commit

Permalink
[#1760] PR feedback: fixed plugin to not show when empty or not logge…
Browse files Browse the repository at this point in the history
…d-in, fixed html of case_status_changed message
  • Loading branch information
Bart van der Schoor committed Jan 11, 2024
1 parent d36eef4 commit 7c91b42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n icon_tags %}


{% if userfeed %}
<section class="userfeed">
<h2 class="h2 {% if userfeed.action_required %}indicator{% endif %}">
{% trans "Aanvragen updates" %}
Expand Down Expand Up @@ -44,3 +44,4 @@ <h2 class="userfeed__heading">
{# </a>#}
</div>
</section>
{% endif %}
7 changes: 6 additions & 1 deletion src/open_inwoner/userfeed/hooks/case_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.db.models import Q
from django.urls import reverse
from django.utils import timezone
from django.utils.html import escape, format_html
from django.utils.translation import ugettext_lazy as _

from open_inwoner.accounts.models import User
Expand Down Expand Up @@ -68,7 +69,11 @@ def message(self) -> str:
status_text = (
translate_single_status(status_text) or status_text or _("onbekend")
)
return self.base_message.format(status=status_text)
html = escape(self.base_message)
status = format_html('<span class="status">{}</span>', status_text)
html = format_html(html, status=status)

return html

@property
def action_url(self) -> str:
Expand Down
15 changes: 10 additions & 5 deletions src/open_inwoner/userfeed/tests/hooks/test_case_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils.html import strip_tags
from django.utils.html import escape, strip_tags
from django.utils.translation import ugettext as _

from zgw_consumers.api_models.base import factory
Expand Down Expand Up @@ -43,7 +43,10 @@ def test_status_update(self, mock_get_active_app_names: Mock):
self.assertEqual(item.type, FeedItemType.case_status_changed)
self.assertEqual(item.action_required, False)
self.assertEqual(item.is_completed, False)
self.assertEqual(item.message, _("Case status has been changed to 'initial'"))
self.assertEqual(
strip_tags(item.message),
escape(_("Case status has been changed to 'initial'")),
)
self.assertEqual(item.title, case.omschrijving)
self.assertEqual(
item.action_url,
Expand Down Expand Up @@ -83,9 +86,11 @@ def test_status_update(self, mock_get_active_app_names: Mock):
# check item changed
item = feed.items[0]
self.assertEqual(
item.message,
_("Case status has been changed to '{status}'").format(
status="translated status"
strip_tags(item.message),
escape(
_("Case status has been changed to '{status}'").format(
status="translated status"
)
),
)
self.assertEqual(item.title, case.omschrijving)
Expand Down

0 comments on commit 7c91b42

Please sign in to comment.