Skip to content

Commit 1f12141

Browse files
authored
Merge pull request #540 from maykinmedia/fix/539-resultaat-can-be-none
[#539] Handle no resultaat on zaak
2 parents 95cf008 + 342acc8 commit 1f12141

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

backend/src/openarchiefbeheer/logging/tests/test_logevent.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import date
22

3-
from django.test import TestCase
3+
from django.test import TestCase, tag
44

55
from timeline_logger.models import TimelineLog
66

@@ -129,3 +129,33 @@ def test_destruction_list_ready_for_first_review(self):
129129
)
130130
self.assertEqual(extra_data["comment"], "A list to test logging data.")
131131
self.assertEqual(extra_data["number_of_zaken"], 3)
132+
133+
@tag("gh-539")
134+
def test_resultaat_of_zaak_can_be_not_set(self):
135+
user = UserFactory.create(post__can_start_destruction=True)
136+
destruction_list = DestructionListFactory.create(
137+
comment="A list to test logging data.", author=user
138+
)
139+
item = DestructionListItemFactory.create(
140+
destruction_list=destruction_list,
141+
with_zaak=True,
142+
)
143+
item.zaak._expand = {
144+
"zaaktype": {
145+
"url": "http://catalogi-api.nl/catalogi/api/v1/zaakypen/111-111-111",
146+
"identificatie": "ZAAKTYPE-01",
147+
"omschrijving": "ZAAKTYPE 1.0",
148+
"versiedatum": "2024-01-01",
149+
},
150+
# No resultaat present
151+
}
152+
item.zaak.save()
153+
154+
logevent.destruction_list_ready_for_first_review(destruction_list, user)
155+
156+
log = TimelineLog.objects.for_object(destruction_list)[0]
157+
158+
self.assertEqual(
159+
log.extra_data["resultaten"],
160+
[],
161+
)

backend/src/openarchiefbeheer/zaken/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,15 @@ def format_selectielijstklasse_choice(resultaat: Resultaat) -> DropDownChoice:
127127
}
128128

129129

130-
def format_resultaten_choices(resultaten: list[dict]) -> DropDownChoice:
130+
def format_resultaten_choices(resultaten: list[dict | None]) -> DropDownChoice:
131131
result = [
132132
{
133133
"value": resultaat["_expand"]["resultaattype"]["url"],
134134
"label": resultaat["_expand"]["resultaattype"]["omschrijving"],
135135
"extra_data": {"toelichting": resultaat.get("toelichting")},
136136
}
137137
for resultaat in resultaten
138+
if resultaat
138139
]
139140
return result
140141

0 commit comments

Comments
 (0)