Skip to content

Commit 3d1bb50

Browse files
committed
♻️ [#427] Refactor choices to make them consistent
1 parent 3bf1089 commit 3d1bb50

File tree

4 files changed

+6
-31
lines changed

4 files changed

+6
-31
lines changed

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

+1-24
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,12 @@ class Meta:
6161
class ChoiceSerializer(serializers.Serializer):
6262
label = serializers.CharField(help_text=_("The description field of the choice."))
6363
value = serializers.CharField(help_text=_("The URL of the choice."))
64-
extra = serializers.CharField(
64+
extra_data = serializers.JSONField(
6565
help_text=_("Any extra information about this choice."),
6666
required=False,
6767
)
6868

6969

70-
class ZaaktypeChoiceSerializer(serializers.Serializer):
71-
label = serializers.CharField(help_text=_("The description field of the zaaktype."))
72-
value = serializers.CharField(help_text=_("The URL field of the zaaktype."))
73-
extra = serializers.CharField(
74-
help_text=_(
75-
"A combination of the identification and the date on which "
76-
"the zaaktype will no longer be valid (if present)."
77-
),
78-
required=False,
79-
)
80-
81-
82-
class SelectielijstklasseChoicesSerializer(serializers.Serializer):
83-
label = serializers.CharField(
84-
help_text=_(
85-
"The description field of the resultaat from the selectielijst API."
86-
)
87-
)
88-
value = serializers.CharField(
89-
help_text=_("The URL field of the resultaat from the selectielijst API.")
90-
)
91-
92-
9370
class SelectielijstklasseChoicesQueryParamSerializer(serializers.Serializer):
9471
zaak = serializers.URLField(
9572
required=False,

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
from .serializers import (
2626
ChoiceSerializer,
2727
SelectielijstklasseChoicesQueryParamSerializer,
28-
SelectielijstklasseChoicesSerializer,
29-
ZaaktypeChoiceSerializer,
3028
)
3129

3230

@@ -63,7 +61,7 @@ def get_queryset(self):
6361
),
6462
tags=["private"],
6563
responses={
66-
200: ZaaktypeChoiceSerializer(many=True),
64+
200: ChoiceSerializer(many=True),
6765
},
6866
)
6967
@method_decorator(cache_page(60 * 15))
@@ -78,7 +76,7 @@ def get(self, request, *args, **kwargs):
7876
)
7977
zaaktypen_choices = format_zaaktype_choices(zaaktypen)
8078

81-
serializer = ZaaktypeChoiceSerializer(data=zaaktypen_choices, many=True)
79+
serializer = ChoiceSerializer(data=zaaktypen_choices, many=True)
8280
serializer.is_valid(raise_exception=True)
8381
return Response(serializer.data, status=status.HTTP_200_OK)
8482

@@ -93,7 +91,7 @@ class SelectielijstklasseChoicesView(APIView):
9391
),
9492
tags=["private"],
9593
responses={
96-
200: SelectielijstklasseChoicesSerializer,
94+
200: ChoiceSerializer(many=True),
9795
},
9896
parameters=[SelectielijstklasseChoicesQueryParamSerializer],
9997
)

backend/src/openarchiefbeheer/zaken/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
class DropDownChoice:
77
label: str
88
value: str
9-
extra_data: Optional[int] = None
9+
extra_data: Optional[dict] = None

backend/src/openarchiefbeheer/zaken/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def format_selectielijstklasse_choice(resultaat: Resultaat) -> DropDownChoice:
120120
return {
121121
"label": description,
122122
"value": resultaat["url"],
123-
"detail": {
123+
"extra_data": {
124124
"bewaartermijn": resultaat.get("bewaartermijn"),
125125
},
126126
}

0 commit comments

Comments
 (0)