Skip to content

Commit

Permalink
Merge pull request #1434 from open-zaak/feature/1433-documenten-zoek
Browse files Browse the repository at this point in the history
add '_zoek' endpoint for documents
  • Loading branch information
annashamray committed Aug 14, 2023
2 parents 056c8c9 + d0a101c commit dd187f0
Show file tree
Hide file tree
Showing 7 changed files with 706 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/openzaak/components/documenten/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,13 @@ def save(self, **kwargs):
return self.instance


class EIOZoekSerializer(serializers.Serializer):
uuid__in = serializers.ListField(
child=serializers.UUIDField(),
help_text=_("Array of unieke resource identifiers (UUID4)"),
)


class GebruiksrechtenSerializer(serializers.HyperlinkedModelSerializer):
informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
view_name="enkelvoudiginformatieobject-detail",
Expand Down
32 changes: 32 additions & 0 deletions src/openzaak/components/documenten/api/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
AuditTrailViewSet,
AuditTrailViewsetMixin,
)
from vng_api_common.search import SearchMixin
from vng_api_common.viewsets import CheckQueryParamsMixin

from openzaak.utils.data_filtering import ListFilterByAuthorizationsMixin
Expand Down Expand Up @@ -58,6 +59,7 @@
)
from .serializers import (
BestandsDeelSerializer,
EIOZoekSerializer,
EnkelvoudigInformatieObjectCreateLockSerializer,
EnkelvoudigInformatieObjectSerializer,
EnkelvoudigInformatieObjectWithLockSerializer,
Expand Down Expand Up @@ -89,6 +91,7 @@ class EnkelvoudigInformatieObjectViewSet(
CMISConnectionPoolMixin,
ConvertCMISAdapterExceptions,
CheckQueryParamsMixin,
SearchMixin,
NotificationViewSetMixin,
ListFilterByAuthorizationsMixin,
AuditTrailViewsetMixin,
Expand Down Expand Up @@ -195,6 +198,7 @@ class EnkelvoudigInformatieObjectViewSet(
)
lookup_field = "uuid"
serializer_class = EnkelvoudigInformatieObjectSerializer
search_input_serializer_class = EIOZoekSerializer
permission_classes = (InformationObjectAuthRequired,)
required_scopes = {
"list": SCOPE_DOCUMENTEN_ALLES_LEZEN,
Expand All @@ -207,6 +211,7 @@ class EnkelvoudigInformatieObjectViewSet(
"download": SCOPE_DOCUMENTEN_ALLES_LEZEN,
"lock": SCOPE_DOCUMENTEN_LOCK,
"unlock": SCOPE_DOCUMENTEN_LOCK | SCOPE_DOCUMENTEN_GEFORCEERD_UNLOCK,
"_zoek": SCOPE_DOCUMENTEN_ALLES_LEZEN,
}
notifications_kanaal = KANAAL_DOCUMENTEN
audit = AUDIT_DRC
Expand Down Expand Up @@ -365,6 +370,33 @@ def unlock(self, request, *args, **kwargs):
unlock_serializer.save()
return Response(status=status.HTTP_204_NO_CONTENT)

@swagger_auto_schema(request_body=EIOZoekSerializer)
@action(methods=["post"], detail=False)
def _zoek(self, request, *args, **kwargs):
"""
Voer een zoekopdracht uit op (ENKELVOUDIG) INFORMATIEOBJECTen .
Zoeken/filteren gaat normaal via de `list` operatie, deze is echter
niet geschikt voor zoekopdrachten met UUIDs.
"""

# this method is not marked as is_search_action, because the DRC standard
# doesn't include LIST query params as possible request data attributes here
# The related issue which highlights it https://github.com/VNG-Realisatie/gemma-zaken/issues/2294
#
# For now we support only 'uuid__in' input parameter here to adhere to the standard OAS
# Even if the DRC reference implementation doesn't do it

search_input = self.get_search_input()
queryset = self.get_queryset()

for name, value in search_input.items():
queryset = queryset.filter(**{name: value})

return self.get_search_output(queryset)

_zoek.is_page_action = True


@cmis_conditional_retrieve()
class GebruiksrechtenViewSet(
Expand Down

0 comments on commit dd187f0

Please sign in to comment.