Skip to content

Commit f03df81

Browse files
authored
Merge pull request #1505 from maykinmedia/issue/2912-zgw-import-export
[#2912] Fix styling for zgw import-export error messages
2 parents cbdb437 + 43f4177 commit f03df81

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

src/open_inwoner/openzaak/admin.py

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

192192
error_msg_html = format_html_join(
193-
"\n", "<li>{}</li>", error_msg_iterator
193+
"\n", "<p> - {}</p>", error_msg_iterator
194194
)
195-
error_msg_html_ordered = format_html(
195+
error_msg_html = format_html(
196196
_("It was not possible to import the following items:")
197-
+ f"<ol> {error_msg_html} </ol>"
198-
)
199-
self.message_user(
200-
request, error_msg_html_ordered, messages.ERROR
197+
+ f"<div>{error_msg_html}</div>"
201198
)
199+
self.message_user(request, error_msg_html, messages.ERROR)
202200

203201
return HttpResponseRedirect(
204202
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
)

src/open_inwoner/openzaak/tests/test_import_export.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ def test_import_jsonl_missing_statustype_config(self):
372372
)
373373
)
374374
expected_error = ZGWImportError(
375-
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = bogus, "
376-
"ZaakTypeConfig identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789"
375+
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = 'bogus', "
376+
"ZaakTypeConfig identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'"
377377
)
378378
import_expected = dataclasses.asdict(
379379
CatalogusConfigImport(
@@ -418,8 +418,8 @@ def test_import_jsonl_update_statustype_config_missing_zt_config(self):
418418
)
419419
)
420420
expected_error = ZGWImportError(
421-
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = status omschrijving, "
422-
"ZaakTypeConfig identificatie = bogus, Catalogus domein = DM-1, Catalogus rsin = 666666666"
421+
"ZaakTypeStatusTypeConfig not found in target environment: omschrijving = 'status omschrijving', "
422+
"ZaakTypeConfig identificatie = 'bogus', Catalogus domein = 'DM-1', Catalogus rsin = '666666666'"
423423
)
424424
import_expected = dataclasses.asdict(
425425
CatalogusConfigImport(
@@ -464,8 +464,8 @@ def test_import_jsonl_update_reports_duplicates(self):
464464
)
465465
)
466466
expected_error = ZGWImportError(
467-
"Got multiple results for ZaakTypeResultaatTypeConfig: omschrijving = resultaat, "
468-
"ZaakTypeConfig identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789"
467+
"Got multiple results for ZaakTypeResultaatTypeConfig: omschrijving = 'resultaat', "
468+
"ZaakTypeConfig identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'"
469469
)
470470
import_expected = dataclasses.asdict(
471471
CatalogusConfigImport(
@@ -509,10 +509,10 @@ def test_import_jsonl_fails_with_catalogus_domein_rsin_mismatch(self):
509509
[
510510
# error from trying to load existing CatalogusConfig
511511
"ERROR:open_inwoner.openzaak.import_export:"
512-
"CatalogusConfig not found in target environment: Domein = BAR, Rsin = 987654321",
512+
"CatalogusConfig not found in target environment: Domein = 'BAR', Rsin = '987654321'",
513513
# error from deserializing nested ZGW objects
514514
"ERROR:open_inwoner.openzaak.import_export:"
515-
"ZaakTypeConfig not found in target environment: Identificatie = ztc-id-a-0, Catalogus domein = DM-0, Catalogus rsin = 123456789",
515+
"ZaakTypeConfig not found in target environment: Identificatie = 'ztc-id-a-0', Catalogus domein = 'DM-0', Catalogus rsin = '123456789'",
516516
],
517517
)
518518

0 commit comments

Comments
 (0)