Skip to content

Commit

Permalink
✨ [#667] Replace selectielijstprocestype with selectielijst klasse
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Feb 6, 2025
1 parent bd5e57b commit 0401694
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
6 changes: 1 addition & 5 deletions backend/src/openarchiefbeheer/zaken/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ def format_selectielijstversie(field: dict, item: DestructionListItem) -> str:
{"name": "Zaak Identificatie", "path": "identificatie"},
{"name": "Zaak Startdatum", "path": "startdatum"},
{"name": "Zaak Einddatum", "path": "einddatum"},
{
"name": "Selectielijst Procestype",
"path": "zaaktype.selectielijst_procestype",
"format": format_selectielijst,
},
{"name": "Selectielijstklasse", "path": "selectielijstklasse"},
{
"name": "Selectielijst versie",
"path": "zaaktype.selectielijst_procestype",
Expand Down
12 changes: 12 additions & 0 deletions backend/src/openarchiefbeheer/zaken/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from rest_framework_gis.fields import GeometryField
from zgw_consumers.models import Service

from openarchiefbeheer.zaken.utils import get_selectielijstklasse_choices_dict

from ..models import Zaak


Expand Down Expand Up @@ -105,6 +107,7 @@ class ZaakMetadataSerializer(serializers.ModelSerializer):
zaaktype = serializers.SerializerMethodField()
resultaat = serializers.SerializerMethodField()
bronapplicatie = serializers.SerializerMethodField()
selectielijstklasse = serializers.SerializerMethodField()

class Meta:
model = Zaak
Expand All @@ -117,6 +120,7 @@ class Meta:
"identificatie",
"zaaktype",
"bronapplicatie",
"selectielijstklasse",
)

@extend_schema_field(serializers.JSONField)
Expand Down Expand Up @@ -152,3 +156,11 @@ def get_bronapplicatie(self, zaak: Zaak) -> str:

service = get_service(zaak_url.url)
return service.label

@extend_schema_field(serializers.CharField)
def get_selectielijstklasse(self, zaak: Zaak) -> str:
if not zaak.selectielijstklasse:
return ""

selectielijstklasse_choices_dict = get_selectielijstklasse_choices_dict()
return selectielijstklasse_choices_dict[zaak.selectielijstklasse]["label"]
11 changes: 11 additions & 0 deletions backend/src/openarchiefbeheer/zaken/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Callable, Generator, Iterable, Literal

from django.conf import settings
from django.core.cache import cache
from django.utils.translation import gettext as _

from ape_pie import APIClient
Expand Down Expand Up @@ -197,6 +198,16 @@ def retrieve_selectielijstklasse_choices(query_params: HashableDict | None) -> l
return results


def get_selectielijstklasse_choices_dict() -> dict[str, DropDownChoice]:
if selectielijstklasse_dict := cache.get("selectielijstklasse_dict"):
return selectielijstklasse_dict

results = retrieve_selectielijstklasse_choices()
results = {result["value"]: result for result in results}
cache.set("selectielijstklasse_dict", results)
return results


@lru_cache
def retrieve_selectielijstklasse_resultaat(resultaat_url: str) -> dict:
config = APIConfig.get_solo()
Expand Down

0 comments on commit 0401694

Please sign in to comment.