Skip to content

Commit 313aa11

Browse files
pi-sigmaswrichards
authored andcommitted
[#2912] Fix styling for zgw import-export error messages
1 parent e143d2a commit 313aa11

File tree

4 files changed

+69
-167
lines changed

4 files changed

+69
-167
lines changed

src/open_inwoner/openzaak/admin.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,13 @@ def process_file_view(self, request):
184184
error_msg_iterator = ([msg] for msg in msgs_deduped)
185185

186186
error_msg_html = format_html_join(
187-
"\n", "<li>{}</li>", error_msg_iterator
187+
"\n", "<p> - {}</p>", error_msg_iterator
188188
)
189-
error_msg_html_ordered = format_html(
189+
error_msg_html = format_html(
190190
_("It was not possible to import the following items:")
191-
+ f"<ol> {error_msg_html} </ol>"
192-
)
193-
self.message_user(
194-
request, error_msg_html_ordered, messages.ERROR
191+
+ f"<div>{error_msg_html}</div>"
195192
)
193+
self.message_user(request, error_msg_html, messages.ERROR)
196194

197195
return HttpResponseRedirect(
198196
reverse(

src/open_inwoner/openzaak/import_export.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,25 @@ def extract_error_data(cls, exc: Exception, jsonl: str):
4343
fields = data.get("fields", None)
4444
if source_config is CatalogusConfig:
4545
items = [
46-
f"Domein = {fields['domein']}",
47-
f"Rsin = {fields['rsin']}",
46+
f"Domein = {fields['domein']!r}",
47+
f"Rsin = {fields['rsin']!r}",
4848
]
4949
if source_config is ZaakTypeConfig:
5050
items = [
51-
f"Identificatie = {fields['identificatie']}",
52-
f"Catalogus domein = {fields['catalogus'][0]}",
53-
f"Catalogus rsin = {fields['catalogus'][1]}",
51+
f"Identificatie = {fields['identificatie']!r}",
52+
f"Catalogus domein = {fields['catalogus'][0]!r}",
53+
f"Catalogus rsin = {fields['catalogus'][1]!r}",
5454
]
5555
if source_config in {
5656
ZaakTypeStatusTypeConfig,
5757
ZaakTypeResultaatTypeConfig,
5858
ZaakTypeInformatieObjectTypeConfig,
5959
}:
6060
items = [
61-
f"omschrijving = {fields['omschrijving']}",
62-
f"ZaakTypeConfig identificatie = {fields['zaaktype_config'][0]}",
63-
f"Catalogus domein = {fields['zaaktype_config'][1]}",
64-
f"Catalogus rsin = {fields['zaaktype_config'][2]}",
61+
f"omschrijving = {fields['omschrijving']!r}",
62+
f"ZaakTypeConfig identificatie = {fields['zaaktype_config'][0]!r}",
63+
f"Catalogus domein = {fields['zaaktype_config'][1]!r}",
64+
f"Catalogus rsin = {fields['zaaktype_config'][2]!r}",
6565
]
6666

6767
return {

src/open_inwoner/openzaak/tests/test_admin.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import html
12
import json
23
from unittest import mock
34

@@ -280,39 +281,39 @@ def test_import_flow_reports_errors(self) -> None:
280281

281282
response = form.submit().follow()
282283

283-
messages = [str(msg) for msg in response.context["messages"]]
284+
messages = [html.unescape(str(msg)) for msg in response.context["messages"]]
284285
self.assertEqual(len(messages), 2)
285286
self.assertEqual(
286287
_("6 item(s) processed in total, with 6 failing row(s)."),
287288
messages[0],
288289
)
289290
self.assertIn(
290-
"ZaakTypeConfig not found in target environment: Identificatie = ztc-id-a-0, "
291-
"Catalogus domein = DM-0, Catalogus rsin = 123456789",
291+
"ZaakTypeConfig not found in target environment: Identificatie = 'ztc-id-a-0', "
292+
"Catalogus domein = 'DM-0', Catalogus rsin = '123456789'",
292293
messages[1],
293294
)
294295
self.assertIn(
295-
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = status omschrijving, "
296-
"ZaakTypeConfig identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789",
296+
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = 'status omschrijving', "
297+
"ZaakTypeConfig identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'",
297298
messages[1],
298299
)
299300
self.assertIn(
300-
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = bogus, ZaakTypeConfig "
301-
"identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789",
301+
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = 'bogus', ZaakTypeConfig "
302+
"identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'",
302303
messages[1],
303304
)
304305
self.assertIn(
305-
"ZaakTypeInformatieObjectTypeConfig not found in target environment: omschrijving = informatieobject, "
306-
"ZaakTypeConfig identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789",
306+
"ZaakTypeInformatieObjectTypeConfig not found in target environment: omschrijving = 'informatieobject', "
307+
"ZaakTypeConfig identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'",
307308
messages[1],
308309
)
309310
self.assertIn(
310-
"CatalogusConfig not found in target environment: Domein = DM-0, Rsin = 123456789",
311+
"CatalogusConfig not found in target environment: Domein = 'DM-0', Rsin = '123456789'",
311312
messages[1],
312313
)
313314
self.assertIn(
314-
"ZaakTypeResultaatTypeConfig not found in target environment: omschrijving = resultaat, "
315-
"ZaakTypeConfig identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789",
315+
"ZaakTypeResultaatTypeConfig not found in target environment: omschrijving = 'resultaat', "
316+
"ZaakTypeConfig identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'",
316317
messages[1],
317318
)
318319

@@ -341,13 +342,13 @@ def test_import_flow_reports_partial_errors(self) -> None:
341342

342343
response = form.submit().follow()
343344

344-
messages = [str(msg) for msg in response.context["messages"]]
345+
messages = [html.unescape(str(msg)) for msg in response.context["messages"]]
345346
self.assertEqual(len(messages), 2)
346347
self.assertEqual(
347348
_("2 item(s) processed in total, with 1 failing row(s)."),
348349
messages[0],
349350
)
350351
self.assertEqual(
351-
"It was not possible to import the following items:<ol> <li>ZaakTypeConfig not found in target environment: Identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789</li> </ol>",
352+
"It was not possible to import the following items:<div><p> - ZaakTypeConfig not found in target environment: Identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'</p></div>",
352353
messages[1],
353354
)

0 commit comments

Comments
 (0)