Skip to content

Commit 0544ba9

Browse files
authored
Merge pull request #741 from maykinmedia/fix/726-settings-report
[#726] Fix settings for destruction report
2 parents 74f8628 + 78d6632 commit 0544ba9

10 files changed

+169
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Generated by Django 4.2.18 on 2025-03-11 11:18
2+
3+
from django.db import migrations, models
4+
5+
6+
# Make sure the configuration is cleared. This is a change that we
7+
# cannot automatically make, so we make sure that the field is cleared
8+
# so that the health check can flag it.
9+
def clear_zaaktype_config(apps, schema_editor):
10+
ArchiveConfig = apps.get_model("config", "ArchiveConfig")
11+
12+
config = ArchiveConfig.objects.first()
13+
if not config:
14+
return
15+
16+
config.zaaktype = ""
17+
config.save()
18+
19+
20+
class Migration(migrations.Migration):
21+
22+
dependencies = [
23+
("config", "0006_alter_archiveconfig_zaaktypes_short_process"),
24+
]
25+
26+
operations = [
27+
migrations.AlterField(
28+
model_name="archiveconfig",
29+
name="zaaktype",
30+
field=models.CharField(
31+
blank=True,
32+
help_text="The identificatie of the zaaktype to use when creating the case for the destruction list deletion.",
33+
max_length=1000,
34+
verbose_name="zaaktype",
35+
),
36+
),
37+
migrations.RunPython(clear_zaaktype_config, clear_zaaktype_config),
38+
]

backend/src/openarchiefbeheer/config/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class ArchiveConfig(SingletonModel):
2424
blank=True,
2525
help_text=_("Source organisation RSIN"),
2626
)
27-
zaaktype = models.URLField(
27+
zaaktype = models.CharField(
2828
"zaaktype",
2929
blank=True,
3030
max_length=1000,
3131
help_text=_(
32-
"The case type URL to use when creating the case for the destruction list deletion."
32+
"The identificatie of the zaaktype to use when creating the case for the destruction list deletion."
3333
),
3434
)
3535
statustype = models.URLField(

backend/src/openarchiefbeheer/zaken/api/mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ def get_query_params(self, request: Request) -> HashableDict:
1010
serializer = ZaaktypeFilterSerializer(data=request.query_params)
1111
serializer.is_valid(raise_exception=True)
1212
query_params = HashableDict()
13-
query_params.update(serializer.validated_data)
13+
query_params.update(serializer.data)
1414

1515
return query_params

backend/src/openarchiefbeheer/zaken/api/serializers.py

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django.utils.translation import gettext_lazy as _
44

5+
from djangorestframework_camel_case.util import camelize
56
from drf_spectacular.utils import extend_schema_field
67
from furl import furl
78
from rest_framework import serializers
@@ -96,6 +97,13 @@ class ZaaktypeFilterSerializer(serializers.Serializer):
9697
required=False,
9798
help_text=_("The URL of the zaaktype on which to filter."),
9899
)
100+
zaaktype_identificatie = serializers.CharField(
101+
required=False,
102+
help_text=_("The identificatie of the zaaktype on which to filter."),
103+
)
104+
105+
def to_representation(self, instance):
106+
return camelize(instance)
99107

100108

101109
@lru_cache

backend/src/openarchiefbeheer/zaken/api/views.py

+32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from rest_framework import status
1111
from rest_framework.exceptions import ValidationError
1212
from rest_framework.permissions import IsAdminUser, IsAuthenticated
13+
from rest_framework.request import Request
1314
from rest_framework.response import Response
1415
from rest_framework.views import APIView
1516

@@ -253,6 +254,37 @@ def get(self, request, *args, **kwargs):
253254
class InformatieobjecttypeChoicesView(FilterOnZaaktypeMixin, APIView):
254255
permission_classes = [IsAuthenticated]
255256

257+
# TODO
258+
# Remove once https://github.com/open-zaak/open-zaak/issues/1939 is fixed
259+
def get_query_params(self, request: Request) -> HashableDict:
260+
"""
261+
We need to filter the informatieobjecttypen on zaaktype URL, but we only have the identificatie.
262+
The identificatie can represent multiple versions of the zaaktype (multiple URLs).
263+
As a bandaid fix, we use the URL of the latest version (highest begin_geldigheid field).
264+
"""
265+
query_params = HashableDict()
266+
if not request.GET.get("zaaktype_identificatie"):
267+
return query_params
268+
269+
serializer = ZaaktypeFilterSerializer(data=request.query_params)
270+
serializer.is_valid(raise_exception=True)
271+
272+
zaaktypen_query_params = HashableDict()
273+
zaaktypen_query_params.update(
274+
{"identificatie": serializer.validated_data["zaaktype_identificatie"]}
275+
)
276+
zaaktypen = retrieve_zaaktypen(zaaktypen_query_params)
277+
if not zaaktypen:
278+
return query_params
279+
280+
# Sort in descending order, so that the zaaktype with the most recent begin date is first. (Latest zaaktype version)
281+
zaaktypen = sorted(
282+
zaaktypen, key=lambda zaaktype: zaaktype["begin_geldigheid"], reverse=True
283+
)
284+
query_params.update({"zaaktype": zaaktypen[0]["url"]})
285+
286+
return query_params
287+
256288
@extend_schema(
257289
summary=_("Retrieve informatieobjecttypen choices"),
258290
description=_(

backend/src/openarchiefbeheer/zaken/tests/vcr/cassettes/InformatieobjecttypenChoicesViewTests.test_retrieve_choices_with_filters.yaml

+65-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,64 @@ interactions:
77
Accept-Encoding:
88
- gzip, deflate, br
99
Authorization:
10-
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0LXZjciIsImlhdCI6MTczOTc5Nzc1NCwiY2xpZW50X2lkIjoidGVzdC12Y3IiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.yLGVdWLUP1fTlN1e_AGBtF8A_OS1Aon2Ky_t-rLb9eY
10+
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0LXZjciIsImlhdCI6MTc0MTY5MjMxMywiY2xpZW50X2lkIjoidGVzdC12Y3IiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.STB3xuL_Kixe2V2Fo-3RlB1dMU_A_a7KZd4qKAEPO3w
11+
Connection:
12+
- keep-alive
13+
User-Agent:
14+
- python-requests/2.32.3
15+
method: GET
16+
uri: http://localhost:8003/catalogi/api/v1/zaaktypen?identificatie=ZAAKTYPE-2018-0000000001
17+
response:
18+
body:
19+
string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/be210495-20b6-48ff-8d3d-3e44f74c43a4","identificatie":"ZAAKTYPE-2018-0000000001","omschrijving":"brand
20+
world-class initiatives","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"","doel":"Trouble
21+
red compare produce animal. Everything today Democrat student enter. By probably
22+
adult.","aanleiding":"Couple toward trip old nice memory system instead.","toelichting":"","indicatieInternOfExtern":"extern","handelingInitiator":"indienen","onderwerp":"Evenementvergunning","handelingBehandelaar":"uitvoeren","doorlooptijd":"P30D","servicenorm":null,"opschortingEnAanhoudingMogelijk":true,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":true,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":["https://example.com/product/123"],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"ReferentieProces
23+
0","link":""},"concept":false,"verantwoordelijke":"100000000","beginGeldigheid":"2018-01-01","eindeGeldigheid":null,"versiedatum":"2018-01-01","beginObject":"2018-01-01","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/ec77ad39-0954-4aeb-bcf2-6f45263cde77","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/9438e56a-5d78-4dc8-9d9a-2404781f818d"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/12903100-b7a0-4441-9645-eda7df2ad106"],"eigenschappen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/a8089bdf-72d3-414f-a9cd-953cfa602b6c"],"roltypen":[],"besluittypen":["http://localhost:8003/catalogi/api/v1/besluittypen/588d7ec5-89e6-4aa0-a654-7475f0d5ac8e"],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}]}'
24+
headers:
25+
API-version:
26+
- 1.3.1
27+
Allow:
28+
- GET, POST, HEAD, OPTIONS
29+
Connection:
30+
- keep-alive
31+
Content-Length:
32+
- '1905'
33+
Content-Security-Policy:
34+
- 'frame-src ''self''; img-src ''self'' data: cdn.redoc.ly cdnjs.cloudflare.com
35+
*.tile.openstreetmap.org; font-src ''self'' fonts.gstatic.com; default-src
36+
''self''; worker-src ''self'' blob:; object-src ''none''; script-src ''self''
37+
''unsafe-inline'' cdnjs.cloudflare.com; style-src ''self'' ''unsafe-inline''
38+
fonts.googleapis.com cdnjs.cloudflare.com; form-action ''self''; frame-ancestors
39+
''none''; base-uri ''self''; connect-src ''self'' raw.githubusercontent.com'
40+
Content-Type:
41+
- application/json
42+
Cross-Origin-Opener-Policy:
43+
- same-origin
44+
Date:
45+
- Tue, 11 Mar 2025 11:25:13 GMT
46+
Referrer-Policy:
47+
- same-origin
48+
Server:
49+
- nginx/1.27.0
50+
Vary:
51+
- Accept, origin
52+
X-Content-Type-Options:
53+
- nosniff
54+
X-Frame-Options:
55+
- DENY
56+
status:
57+
code: 200
58+
message: OK
59+
- request:
60+
body: null
61+
headers:
62+
Accept:
63+
- '*/*'
64+
Accept-Encoding:
65+
- gzip, deflate, br
66+
Authorization:
67+
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0LXZjciIsImlhdCI6MTc0MTY5MjMxMywiY2xpZW50X2lkIjoidGVzdC12Y3IiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.STB3xuL_Kixe2V2Fo-3RlB1dMU_A_a7KZd4qKAEPO3w
1168
Connection:
1269
- keep-alive
1370
User-Agent:
@@ -30,18 +87,18 @@ interactions:
3087
Content-Length:
3188
- '1137'
3289
Content-Security-Policy:
33-
- 'img-src ''self'' data: cdn.redoc.ly cdnjs.cloudflare.com *.tile.openstreetmap.org;
34-
object-src ''none''; script-src ''self'' ''unsafe-inline'' cdnjs.cloudflare.com;
35-
worker-src ''self'' blob:; form-action ''self''; style-src ''self'' ''unsafe-inline''
36-
fonts.googleapis.com cdnjs.cloudflare.com; default-src ''self''; frame-src
37-
''self''; font-src ''self'' fonts.gstatic.com; frame-ancestors ''none''; connect-src
38-
''self'' raw.githubusercontent.com; base-uri ''self'''
90+
- 'frame-src ''self''; img-src ''self'' data: cdn.redoc.ly cdnjs.cloudflare.com
91+
*.tile.openstreetmap.org; font-src ''self'' fonts.gstatic.com; default-src
92+
''self''; worker-src ''self'' blob:; object-src ''none''; script-src ''self''
93+
''unsafe-inline'' cdnjs.cloudflare.com; style-src ''self'' ''unsafe-inline''
94+
fonts.googleapis.com cdnjs.cloudflare.com; form-action ''self''; frame-ancestors
95+
''none''; base-uri ''self''; connect-src ''self'' raw.githubusercontent.com'
3996
Content-Type:
4097
- application/json
4198
Cross-Origin-Opener-Policy:
4299
- same-origin
43100
Date:
44-
- Mon, 17 Feb 2025 13:09:14 GMT
101+
- Tue, 11 Mar 2025 11:25:13 GMT
45102
Referrer-Policy:
46103
- same-origin
47104
Server:

backend/src/openarchiefbeheer/zaken/tests/vcr/cassettes/ResultaattypenChoicesViewTests.test_retrieve_choices_with_filters.yaml

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ interactions:
77
Accept-Encoding:
88
- gzip, deflate, br
99
Authorization:
10-
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0LXZjciIsImlhdCI6MTczNjg1MTA1NCwiY2xpZW50X2lkIjoidGVzdC12Y3IiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.lxTut69IIIa6tkLAkRO51N7KMonJQGK07R_BNpLTz8o
10+
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0LXZjciIsImlhdCI6MTc0MTY5MjQwNSwiY2xpZW50X2lkIjoidGVzdC12Y3IiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.NHP1eJnPCGTK0pYNWCzip8OPXjuV8lV3oD_RDJFXyCc
1111
Connection:
1212
- keep-alive
1313
User-Agent:
1414
- python-requests/2.32.3
1515
method: GET
16-
uri: http://localhost:8003/catalogi/api/v1/resultaattypen?zaaktype=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fzaaktypen%2Fbe210495-20b6-48ff-8d3d-3e44f74c43a4
16+
uri: http://localhost:8003/catalogi/api/v1/resultaattypen?zaaktypeIdentificatie=ZAAKTYPE-2018-0000000001
1717
response:
1818
body:
1919
string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/resultaattypen/12903100-b7a0-4441-9645-eda7df2ad106","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/be210495-20b6-48ff-8d3d-3e44f74c43a4","zaaktypeIdentificatie":"ZAAKTYPE-2018-0000000001","omschrijving":"Successful","resultaattypeomschrijving":"Successful","omschrijvingGeneriek":"","selectielijstklasse":"https://selectielijst.openzaak.nl/api/v1/resultaten/cc5ae4e3-a9e6-4386-bcee-46be4986a829","toelichting":"","archiefnominatie":"","archiefactietermijn":null,"brondatumArchiefprocedure":{"afleidingswijze":"","datumkenmerk":"","einddatumBekend":false,"objecttype":"","registratie":"","procestermijn":null},"procesobjectaard":"","indicatieSpecifiek":null,"procestermijn":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/ec77ad39-0954-4aeb-bcf2-6f45263cde77","besluittypen":[],"besluittypeOmschrijving":[],"informatieobjecttypen":[],"informatieobjecttypeOmschrijving":[],"beginGeldigheid":null,"eindeGeldigheid":null,"beginObject":null,"eindeObject":null}]}'
@@ -26,12 +26,19 @@ interactions:
2626
- keep-alive
2727
Content-Length:
2828
- '1088'
29+
Content-Security-Policy:
30+
- 'frame-src ''self''; img-src ''self'' data: cdn.redoc.ly cdnjs.cloudflare.com
31+
*.tile.openstreetmap.org; font-src ''self'' fonts.gstatic.com; default-src
32+
''self''; worker-src ''self'' blob:; object-src ''none''; script-src ''self''
33+
''unsafe-inline'' cdnjs.cloudflare.com; style-src ''self'' ''unsafe-inline''
34+
fonts.googleapis.com cdnjs.cloudflare.com; form-action ''self''; frame-ancestors
35+
''none''; base-uri ''self''; connect-src ''self'' raw.githubusercontent.com'
2936
Content-Type:
3037
- application/json
3138
Cross-Origin-Opener-Policy:
3239
- same-origin
3340
Date:
34-
- Tue, 14 Jan 2025 10:37:34 GMT
41+
- Tue, 11 Mar 2025 11:26:45 GMT
3542
Referrer-Policy:
3643
- same-origin
3744
Server:

backend/src/openarchiefbeheer/zaken/tests/vcr/test_views.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ def test_retrieve_choices_with_filters(self):
123123
user = UserFactory.create()
124124

125125
endpoint = furl(reverse("api:retrieve-external-resultaattype-choices"))
126-
endpoint.args["zaaktype"] = (
127-
"http://localhost:8003/catalogi/api/v1/zaaktypen/be210495-20b6-48ff-8d3d-3e44f74c43a4"
128-
)
126+
endpoint.args["zaaktypeIdentificatie"] = "ZAAKTYPE-2018-0000000001"
129127

130128
self.client.force_authenticate(user=user)
131129
response = self.client.get(endpoint.url)
@@ -186,9 +184,7 @@ def test_retrieve_choices_with_filters(self):
186184
user = UserFactory.create()
187185

188186
endpoint = furl(reverse("api:retrieve-informatieobjecttype-choices"))
189-
endpoint.args["zaaktype"] = (
190-
"http://localhost:8003/catalogi/api/v1/zaaktypen/be210495-20b6-48ff-8d3d-3e44f74c43a4"
191-
)
187+
endpoint.args["zaaktypeIdentificatie"] = "ZAAKTYPE-2018-0000000001"
192188

193189
self.client.force_authenticate(user=user)
194190
response = self.client.get(endpoint.url)

frontend/src/lib/api/private.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { request } from "./request";
1010
* the field 'omschrijving'.
1111
*/
1212
export async function listInformatieObjectTypeChoices(
13-
zaaktypeUrl?: string,
13+
zaaktypeIdentificatie?: string,
1414
signal?: AbortSignal,
1515
) {
1616
return cacheMemo(
@@ -20,7 +20,7 @@ export async function listInformatieObjectTypeChoices(
2020
"GET",
2121
"/_informatieobjecttype-choices/",
2222
{
23-
zaaktype: zaaktypeUrl,
23+
zaaktypeIdentificatie: zaaktypeIdentificatie,
2424
},
2525
undefined,
2626
undefined,
@@ -30,7 +30,7 @@ export async function listInformatieObjectTypeChoices(
3030

3131
return promise;
3232
},
33-
[zaaktypeUrl],
33+
[zaaktypeIdentificatie],
3434
);
3535
}
3636

@@ -39,7 +39,7 @@ export async function listInformatieObjectTypeChoices(
3939
* 'omschrijving'.
4040
*/
4141
export async function listStatusTypeChoices(
42-
zaaktypeUrl?: string,
42+
zaaktypeIdentificatie?: string,
4343
signal?: AbortSignal,
4444
) {
4545
return cacheMemo(
@@ -49,7 +49,7 @@ export async function listStatusTypeChoices(
4949
"GET",
5050
"/_statustype-choices/",
5151
{
52-
zaaktype: zaaktypeUrl,
52+
zaaktypeIdentificatie: zaaktypeIdentificatie,
5353
},
5454
undefined,
5555
undefined,
@@ -59,7 +59,7 @@ export async function listStatusTypeChoices(
5959

6060
return promise;
6161
},
62-
[zaaktypeUrl],
62+
[zaaktypeIdentificatie],
6363
);
6464
}
6565

@@ -68,7 +68,7 @@ export async function listStatusTypeChoices(
6868
* resultaattype. The label is the field 'omschrijving'.
6969
*/
7070
export async function listResultaatTypeChoices(
71-
zaaktypeUrl?: string,
71+
zaaktypeIdentificatie?: string,
7272
signal?: AbortSignal,
7373
) {
7474
return cacheMemo(
@@ -78,7 +78,7 @@ export async function listResultaatTypeChoices(
7878
"GET",
7979
"/_external-resultaattype-choices/",
8080
{
81-
zaaktype: zaaktypeUrl,
81+
zaaktypeIdentificatie: zaaktypeIdentificatie,
8282
},
8383
undefined,
8484
undefined,
@@ -88,7 +88,7 @@ export async function listResultaatTypeChoices(
8888

8989
return promise;
9090
},
91-
[zaaktypeUrl],
91+
[zaaktypeIdentificatie],
9292
);
9393
}
9494

@@ -130,7 +130,7 @@ export async function listSelectielijstKlasseChoices(
130130

131131
/**
132132
* Retrieve zaaktypen from Open Zaak and return a value and a label per zaaktype.
133-
* The label is the 'omschrijving' field, and the value is the URL. The response is cached for 15 minutes.
133+
* The label is the 'omschrijving' field, and the value is the identificatie. The response is cached for 15 minutes.
134134
* @param [params] - Additional search parameters for filtering (this keeps filters in sync with objects on page).
135135
* @param [external=false] - Fetch zaaktypen from ZRC Service (Open Zaak) (slower/can't be combined with other filtering options).
136136
* @param signal - Abort signal, should be called in cleanup function in React `useEffect()` hooks.

frontend/src/pages/settings/pages/destruction-report/DestructionReportSettingsPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function DestructionReportSettingsPage() {
6464
[valuesState.zaaktype],
6565
);
6666
const { data: informatieObjectTypeChoices } = useDataFetcher(
67-
(signal) => listInformatieObjectTypeChoices(valuesState.zaakType, signal),
67+
(signal) => listInformatieObjectTypeChoices(valuesState.zaaktype, signal),
6868
{
6969
initialState: [],
7070
errorMessage:

0 commit comments

Comments
 (0)