Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#397] Configuration for creating new zaak #408

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions backend/src/openarchiefbeheer/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
)
from openarchiefbeheer.zaken.api.views import (
CacheZakenView,
InformatieobjecttypeChoicesView,
ResultaattypeChoicesView,
SelectielijstklasseChoicesView,
StatustypeChoicesView,
ZaaktypenChoicesView,
)
from openarchiefbeheer.zaken.api.viewsets import ZakenViewSet
Expand Down Expand Up @@ -111,6 +114,21 @@
SelectielijstklasseChoicesView.as_view(),
name="retrieve-selectielijstklasse-choices",
),
path(
"_statustype-choices/",
StatustypeChoicesView.as_view(),
name="retrieve-statustype-choices",
),
path(
"_informatieobjecttype-choices/",
InformatieobjecttypeChoicesView.as_view(),
name="retrieve-informatieobjecttype-choices",
),
path(
"_resultaattype-choices/",
ResultaattypeChoicesView.as_view(),
name="retrieve-resultaattype-choices",
),
path("", include(router.urls)),
]
),
Expand Down
16 changes: 15 additions & 1 deletion backend/src/openarchiefbeheer/config/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@
class ArchiveConfigSerializer(serializers.ModelSerializer):
class Meta:
model = ArchiveConfig
fields = ("zaaktypes_short_process",)
fields = (
"zaaktypes_short_process",
"bronorganisatie",
"zaaktype",
"statustype",
"resultaattype",
"informatieobjecttype",
)
extra_kwargs = {
"bronorganisatie": {"required": True, "allow_null": False},
"zaaktype": {"required": True, "allow_null": False},
"statustype": {"required": True, "allow_null": False},
"resultaattype": {"required": True, "allow_null": False},
"informatieobjecttype": {"required": True, "allow_null": False},
}
4 changes: 4 additions & 0 deletions backend/src/openarchiefbeheer/config/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def update(self, *, partial: bool = False) -> Response:
tags=["Configuration"],
summary=_("Update archive configuration"),
description=_("Update archive configuration."),
request=ArchiveConfigSerializer,
responses={200: ArchiveConfigSerializer},
)
def put(self, request, *args, **kwargs) -> Response:
return self.update()
Expand All @@ -53,6 +55,8 @@ def put(self, request, *args, **kwargs) -> Response:
tags=["Configuration"],
summary=_("Update archive configuration"),
description=_("Partially update archive configuration."),
request=ArchiveConfigSerializer,
responses={200: ArchiveConfigSerializer},
)
def patch(self, request, *args, **kwargs) -> Response:
return self.update(partial=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Generated by Django 4.2.15 on 2024-10-08 13:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("config", "0003_apiconfig"),
]

operations = [
migrations.AddField(
model_name="archiveconfig",
name="bronorganisatie",
field=models.CharField(
blank=True,
help_text="Source organisation RSIN",
max_length=9,
verbose_name="bronorganisatie",
),
),
migrations.AddField(
model_name="archiveconfig",
name="informatieobjecttype",
field=models.URLField(
blank=True,
help_text="The document type URL to use when creating the case for the destruction list deletion.",
max_length=1000,
verbose_name="informatieobjecttype",
),
),
migrations.AddField(
model_name="archiveconfig",
name="resultaattype",
field=models.URLField(
blank=True,
help_text="The result type URL to use when creating the case for the destruction list deletion.",
max_length=1000,
verbose_name="resultaattype",
),
),
migrations.AddField(
model_name="archiveconfig",
name="statustype",
field=models.URLField(
blank=True,
help_text="The status type URL to use when creating the case for the destruction list deletion.",
max_length=1000,
verbose_name="statustype",
),
),
migrations.AddField(
model_name="archiveconfig",
name="zaaktype",
field=models.URLField(
blank=True,
help_text="The case type URL to use when creating the case for the destruction list deletion.",
max_length=1000,
verbose_name="zaaktype",
),
),
]
39 changes: 39 additions & 0 deletions backend/src/openarchiefbeheer/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,45 @@ class ArchiveConfig(SingletonModel):
blank=True,
)

bronorganisatie = models.CharField(
"bronorganisatie",
max_length=9,
blank=True,
help_text=_("Source organisation RSIN"),
)
zaaktype = models.URLField(
"zaaktype",
blank=True,
max_length=1000,
help_text=_(
"The case type URL to use when creating the case for the destruction list deletion."
),
)
statustype = models.URLField(
"statustype",
blank=True,
max_length=1000,
help_text=_(
"The status type URL to use when creating the case for the destruction list deletion."
),
)
resultaattype = models.URLField(
"resultaattype",
blank=True,
max_length=1000,
help_text=_(
"The result type URL to use when creating the case for the destruction list deletion."
),
)
informatieobjecttype = models.URLField(
"informatieobjecttype",
blank=True,
max_length=1000,
help_text=_(
"The document type URL to use when creating the case for the destruction list deletion."
),
)

class Meta:
verbose_name = _("archive configuration")
verbose_name_plural = _("archive configurations")
Expand Down
9 changes: 8 additions & 1 deletion backend/src/openarchiefbeheer/config/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def test_record_manager_update(self):
self.client.force_login(user)
response = self.client.put(
reverse("api:archive-config"),
data={"zaaktypesShortProcess": ["http://tralala.nl"]},
data={
"zaaktypesShortProcess": ["http://tralala.nl"],
"bronorganisatie": "000000000",
"zaaktype": "http://bla.nl",
"statustype": "http://bla.nl",
"resultaattype": "http://bla.nl",
"informatieobjecttype": "http://bla.nl",
},
)

self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down
9 changes: 9 additions & 0 deletions backend/src/openarchiefbeheer/zaken/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ class Meta:
)


class ChoiceSerializer(serializers.Serializer):
label = serializers.CharField(help_text=_("The description field of the choice."))
value = serializers.CharField(help_text=_("The URL of the choice."))
extra = serializers.CharField(
help_text=_("Any extra information about this choice."),
required=False,
)


class ZaaktypeChoiceSerializer(serializers.Serializer):
label = serializers.CharField(help_text=_("The description field of the zaaktype."))
value = serializers.CharField(help_text=_("The URL field of the zaaktype."))
Expand Down
79 changes: 78 additions & 1 deletion backend/src/openarchiefbeheer/zaken/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@

from ..models import Zaak
from ..tasks import retrieve_and_cache_zaken_from_openzaak
from ..utils import format_zaaktype_choices, retrieve_selectielijstklasse_choices
from ..utils import (
format_zaaktype_choices,
retrieve_paginated_type,
retrieve_selectielijstklasse_choices,
)
from .filtersets import ZaakFilter
from .serializers import (
ChoiceSerializer,
SelectielijstklasseChoicesQueryParamSerializer,
SelectielijstklasseChoicesSerializer,
ZaaktypeChoiceSerializer,
Expand Down Expand Up @@ -108,3 +113,75 @@ def get(self, request, *args, **kwargs):

choices = retrieve_selectielijstklasse_choices(query_params)
return Response(data=choices)


class StatustypeChoicesView(APIView):
permission_classes = [IsAuthenticated]

@extend_schema(
summary=_("Retrieve statustypen choices"),
description=_(
"Retrieve statustypen from Open Zaak and return a "
"value and a label per statustype. The label is the field 'omschrijving'."
),
tags=["private"],
responses={
200: ChoiceSerializer(many=True),
},
)
@method_decorator(cache_page(60 * 15))
def get(self, request, *args, **kwargs):
results = retrieve_paginated_type("statustypen")

serializer = ChoiceSerializer(data=results, many=True)
serializer.is_valid(raise_exception=True)

return Response(serializer.data, status=status.HTTP_200_OK)


class InformatieobjecttypeChoicesView(APIView):
permission_classes = [IsAuthenticated]

@extend_schema(
summary=_("Retrieve informatieobjecttypen choices"),
description=_(
"Retrieve informatieobjecttypen from Open Zaak and return a "
"value and a label per informatieobjecttype. The label is the field 'omschrijving'."
),
tags=["private"],
responses={
200: ChoiceSerializer(many=True),
},
)
@method_decorator(cache_page(60 * 15))
def get(self, request, *args, **kwargs):
results = retrieve_paginated_type("informatieobjecttypen")

serializer = ChoiceSerializer(data=results, many=True)
serializer.is_valid(raise_exception=True)

return Response(serializer.data, status=status.HTTP_200_OK)


class ResultaattypeChoicesView(APIView):
permission_classes = [IsAuthenticated]

@extend_schema(
summary=_("Retrieve resultaattypen choices"),
description=_(
"Retrieve resultaattypen from Open Zaak and return a "
"value and a label per resultaattype. The label is the field 'omschrijving'."
),
tags=["private"],
responses={
200: ChoiceSerializer(many=True),
},
)
@method_decorator(cache_page(60 * 15))
def get(self, request, *args, **kwargs):
results = retrieve_paginated_type("resultaattypen")

serializer = ChoiceSerializer(data=results, many=True)
serializer.is_valid(raise_exception=True)

return Response(serializer.data, status=status.HTTP_200_OK)
Loading
Loading