Beispiel #1
0
class ZaakFilter(FilterSet):
    maximale_vertrouwelijkheidaanduiding = MaximaleVertrouwelijkheidaanduidingFilter(
        field_name="vertrouwelijkheidaanduiding",
        help_text=(
            "Zaken met een vertrouwelijkheidaanduiding die beperkter is dan de "
            "aangegeven aanduiding worden uit de resultaten gefiltered."
        ),
    )

    rol__betrokkene_identificatie__natuurlijk_persoon__inp_bsn = filters.CharFilter(
        field_name="rol__natuurlijkpersoon__inp_bsn",
        help_text=get_help_text("zaken.NatuurlijkPersoon", "inp_bsn"),
    )
    rol__betrokkene_identificatie__medewerker__identificatie = filters.CharFilter(
        field_name="rol__medewerker__identificatie",
        help_text=get_help_text("zaken.Medewerker", "identificatie"),
    )

    class Meta:
        model = Zaak
        fields = {
            "identificatie": ["exact"],
            "bronorganisatie": ["exact"],
            "zaaktype": ["exact"],
            "archiefnominatie": ["exact", "in"],
            "archiefactiedatum": ["exact", "lt", "gt"],
            "archiefstatus": ["exact", "in"],
            "startdatum": ["exact", "gt", "gte", "lt", "lte"],
            # filters for werkvoorraad
            "rol__betrokkene_type": ["exact"],
            "rol__betrokkene": ["exact"],
            "rol__omschrijving_generiek": ["exact"],
        }
Beispiel #2
0
class BesluitTypeSerializer(serializers.HyperlinkedModelSerializer):
    informatieobjecttypes = serializers.HyperlinkedRelatedField(
        view_name="informatieobjecttype-detail",
        many=True,
        lookup_field="uuid",
        queryset=InformatieObjectType.objects.all(),
        help_text=get_help_text("catalogi.BesluitType",
                                "informatieobjecttypes"),
    )

    zaaktypes = serializers.HyperlinkedRelatedField(
        many=True,
        view_name="zaaktype-detail",
        lookup_field="uuid",
        queryset=ZaakType.objects.all(),
        help_text=get_help_text("catalogi.BesluitType", "zaaktypes"),
    )

    class Meta:
        model = BesluitType
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "catalogus": {
                "lookup_field": "uuid"
            },
            "begin_geldigheid": {
                "source": "datum_begin_geldigheid"
            },
            "einde_geldigheid": {
                "source": "datum_einde_geldigheid"
            },
            "concept": {
                "read_only": True
            },
        }
        fields = (
            "url",
            "catalogus",
            "zaaktypes",
            "omschrijving",
            "omschrijving_generiek",
            "besluitcategorie",
            "reactietermijn",
            "publicatie_indicatie",
            "publicatietekst",
            "publicatietermijn",
            "toelichting",
            "informatieobjecttypes",
            "begin_geldigheid",
            "einde_geldigheid",
            "concept",
        )
        validators = [
            UniqueTogetherValidator(queryset=BesluitType.objects.all(),
                                    fields=["catalogus", "omschrijving"]),
            RelationCatalogValidator("informatieobjecttypes"),
            RelationCatalogValidator("zaaktypes"),
        ]
Beispiel #3
0
class BesluitTypeSerializer(serializers.HyperlinkedModelSerializer):
    informatieobjecttypes = serializers.HyperlinkedRelatedField(
        view_name='informatieobjecttype-detail',
        many=True,
        lookup_field='uuid',
        queryset=InformatieObjectType.objects.all(),
        help_text=get_help_text('datamodel.BesluitType',
                                'informatieobjecttypes'))

    zaaktypes = serializers.HyperlinkedRelatedField(
        many=True,
        view_name='zaaktype-detail',
        lookup_field='uuid',
        queryset=ZaakType.objects.all(),
        help_text=get_help_text('datamodel.BesluitType', 'zaaktypes'))

    class Meta:
        model = BesluitType
        extra_kwargs = {
            'url': {
                'lookup_field': 'uuid',
            },
            'catalogus': {
                'lookup_field': 'uuid',
            },
            'begin_geldigheid': {
                'source': 'datum_begin_geldigheid'
            },
            'einde_geldigheid': {
                'source': 'datum_einde_geldigheid'
            },
            'concept': {
                'read_only': True,
            },
        }
        fields = (
            'url',
            'catalogus',
            'zaaktypes',
            'omschrijving',
            'omschrijving_generiek',
            'besluitcategorie',
            'reactietermijn',
            'publicatie_indicatie',
            'publicatietekst',
            'publicatietermijn',
            'toelichting',
            'informatieobjecttypes',
            'begin_geldigheid',
            'einde_geldigheid',
            'concept',
        )
        validators = [
            UniqueTogetherValidator(
                queryset=BesluitType.objects.all(),
                fields=['catalogus', 'omschrijving'],
            ),
            RelationCatalogValidator('informatieobjecttypes'),
            RelationCatalogValidator('zaaktypes'),
        ]
Beispiel #4
0
class GebruiksrechtenSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name="enkelvoudiginformatieobject-detail",
        lookup_field="uuid",
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text("datamodel.Gebruiksrechten",
                                "informatieobject"),
    )

    class Meta:
        model = Gebruiksrechten
        fields = (
            "url",
            "informatieobject",
            "startdatum",
            "einddatum",
            "omschrijving_voorwaarden",
        )
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "informatieobject": {
                "validators": [IsImmutableValidator()]
            },
        }
Beispiel #5
0
class ObjectInformatieObjectFilter(FilterSet):
    informatieobject = URLModelChoiceFilter(
        queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
        instance_path="canonical",
        help_text=get_help_text(
            "documenten.ObjectInformatieObject", "informatieobject"
        ),
    )
    object = ObjectFilter(
        queryset=ObjectInformatieObject.objects.all(),
        help_text=_(
            "URL-referentie naar het gerelateerde OBJECT (in deze of een andere API)."
        ),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = ("object", "informatieobject")

    def filter_queryset(self, queryset):
        if settings.CMIS_ENABLED and self.data.get("informatieobject") is not None:
            # The cleaned value for informatieobject needs to be reset since a url_to_pk function
            # makes its value None when CMIS is enabled (as the eio object has no PK).
            self.form.cleaned_data["informatieobject"] = self.data["informatieobject"]
            qs = super().filter_queryset(queryset)
            # Refresh queryset
            qs._result_cache = None
            return qs
        return super().filter_queryset(queryset)
Beispiel #6
0
class GebruiksrechtenSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name='enkelvoudiginformatieobject-detail',
        lookup_field='uuid',
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text('datamodel.Gebruiksrechten', 'informatieobject'),
    )

    class Meta:
        model = Gebruiksrechten
        fields = (
            'url',
            'informatieobject',
            'startdatum',
            'einddatum',
            'omschrijving_voorwaarden'
        )
        extra_kwargs = {
            'url': {
                'lookup_field': 'uuid',
            },
            'informatieobject': {
                'validators': [IsImmutableValidator()],
            },
        }
Beispiel #7
0
class ResultaatSerializer(serializers.HyperlinkedModelSerializer):
    resultaattype = LengthHyperlinkedRelatedField(
        view_name="resultaattype-detail",
        lookup_field="uuid",
        queryset=ResultaatType.objects.all(),
        max_length=1000,
        min_length=1,
        validators=[IsImmutableValidator()],
        help_text=get_help_text("zaken.Resultaat", "resultaattype"),
    )

    class Meta:
        model = Resultaat
        fields = ("url", "uuid", "zaak", "resultaattype", "toelichting")
        validators = [CorrectZaaktypeValidator("resultaattype")]
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "uuid": {
                "read_only": True
            },
            "zaak": {
                "lookup_field": "uuid"
            },
        }
Beispiel #8
0
class RolFilter(FilterSet):
    betrokkene_identificatie__natuurlijk_persoon__inp_bsn = filters.CharFilter(
        field_name="natuurlijkpersoon__inp_bsn",
        help_text=get_help_text("zaken.NatuurlijkPersoon", "inp_bsn"),
    )
    betrokkene_identificatie__natuurlijk_persoon__anp_identificatie = filters.CharFilter(
        field_name="natuurlijkpersoon__anp_identificatie",
        help_text=get_help_text("zaken.NatuurlijkPersoon",
                                "anp_identificatie"),
    )
    betrokkene_identificatie__natuurlijk_persoon__inp_a_nummer = filters.CharFilter(
        field_name="natuurlijkpersoon__inp_a_nummer",
        help_text=get_help_text("zaken.NatuurlijkPersoon", "inp_a_nummer"),
    )
    betrokkene_identificatie__niet_natuurlijk_persoon__inn_nnp_id = filters.CharFilter(
        field_name="nietnatuurlijkpersoon__inn_nnp_id",
        help_text=get_help_text("zaken.NietNatuurlijkPersoon", "inn_nnp_id"),
    )
    betrokkene_identificatie__niet_natuurlijk_persoon__ann_identificatie = filters.CharFilter(
        field_name="nietnatuurlijkpersoon__ann_identificatie",
        help_text=get_help_text("zaken.NietNatuurlijkPersoon",
                                "ann_identificatie"),
    )
    betrokkene_identificatie__vestiging__vestigings_nummer = filters.CharFilter(
        field_name="vestiging__vestigings_nummer",
        help_text=get_help_text("zaken.Vestiging", "vestigings_nummer"),
    )
    betrokkene_identificatie__vestiging__identificatie = filters.CharFilter(
        field_name="organisatorischeeenheid__identificatie",
        help_text=get_help_text("zaken.OrganisatorischeEenheid",
                                "identificatie"),
    )
    betrokkene_identificatie__medewerker__identificatie = filters.CharFilter(
        field_name="medewerker__identificatie",
        help_text=get_help_text("zaken.Medewerker", "identificatie"),
    )

    class Meta:
        model = Rol
        fields = (
            "zaak",
            "betrokkene",
            "betrokkene_type",
            "betrokkene_identificatie__natuurlijk_persoon__inp_bsn",
            "betrokkene_identificatie__natuurlijk_persoon__anp_identificatie",
            "betrokkene_identificatie__natuurlijk_persoon__inp_a_nummer",
            "betrokkene_identificatie__niet_natuurlijk_persoon__inn_nnp_id",
            "betrokkene_identificatie__niet_natuurlijk_persoon__ann_identificatie",
            "betrokkene_identificatie__vestiging__vestigings_nummer",
            "betrokkene_identificatie__vestiging__identificatie",
            "betrokkene_identificatie__medewerker__identificatie",
            "roltype",
            "omschrijving",
            "omschrijving_generiek",
        )
class VerzoekProductFilter(FilterSet):
    product_identificatie__code = filters.CharFilter(
        field_name="product_code",
        help_text=get_help_text("datamodel.VerzoekProduct", "product_code"),
    )

    class Meta:
        model = VerzoekProduct
        fields = ("verzoek", "product", "product_identificatie__code")
Beispiel #10
0
class ObjectTypeFilterSet(FilterSet):
    dataClassification = filters.ChoiceFilter(
        field_name="data_classification",
        choices=DataClassificationChoices.choices,
        help_text=get_help_text("core.ObjectType", "data_classification"),
    )

    class Meta:
        model = ObjectType
        fields = ("dataClassification", )
Beispiel #11
0
class ZaakInformatieObjectFilter(FilterSet):
    informatieobject = FkOrUrlFieldFilter(
        queryset=ZaakInformatieObject.objects.all(),
        instance_path="canonical",
        help_text=get_help_text("zaken.ZaakInformatieObject", "informatieobject"),
    )

    class Meta:
        model = ZaakInformatieObject
        fields = ("zaak", "informatieobject")
Beispiel #12
0
class BesluitInformatieObjectFilter(FilterSet):
    informatieobject = FkOrUrlFieldFilter(
        queryset=BesluitInformatieObject.objects.all(),
        instance_path="canonical",
        help_text=get_help_text("besluiten.BesluitInformatieObject",
                                "informatieobject"),
    )

    class Meta:
        model = BesluitInformatieObject
        fields = ("besluit", "informatieobject")
class ObjectInformatieObjectFilter(FilterSet):
    informatieobject = URLModelChoiceFilter(
        queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
        instance_path="canonical",
        help_text=get_help_text("datamodel.ObjectInformatieObject",
                                "informatieobject"),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = ("object", "informatieobject")
Beispiel #14
0
class GebruiksrechtenFilter(FilterSet):
    informatieobject = URLModelChoiceFilter(
        queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
        instance_path="canonical",
        help_text=get_help_text("documenten.Gebruiksrechten", "informatieobject"),
    )

    class Meta:
        model = Gebruiksrechten
        fields = {
            "informatieobject": ["exact"],
            "startdatum": ["lt", "lte", "gt", "gte"],
            "einddatum": ["lt", "lte", "gt", "gte"],
        }
Beispiel #15
0
class GebruiksrechtenSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name="enkelvoudiginformatieobject-detail",
        lookup_field="uuid",
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text("documenten.Gebruiksrechten",
                                "informatieobject"),
    )

    class Meta:
        model = Gebruiksrechten
        fields = (
            "url",
            "informatieobject",
            "startdatum",
            "einddatum",
            "omschrijving_voorwaarden",
        )
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "informatieobject": {
                "validators": [IsImmutableValidator()]
            },
        }

    def create(self, validated_data):
        if settings.CMIS_ENABLED:
            # The URL of the EnkelvoudigInformatieObject is needed rather than the canonical object
            if validated_data.get("informatieobject") is not None:
                validated_data["informatieobject"] = self.initial_data[
                    "informatieobject"]
        return super().create(validated_data)

    def to_representation(self, instance):
        ret = super().to_representation(instance)
        # With Alfresco, the URL of the Gebruiksrechten and EnkelvoudigInformatieObject
        # cannot be retrieved using the latest_version property of the canonical object
        if settings.CMIS_ENABLED:
            path = reverse("gebruiksrechten-detail",
                           kwargs={
                               "version": 1,
                               "uuid": instance.uuid
                           })
            ret["url"] = make_absolute_uri(path,
                                           request=self.context.get("request"))
            ret["informatieobject"] = instance.get_informatieobject_url()
        return ret
Beispiel #16
0
class ObjectInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name="enkelvoudiginformatieobject-detail",
        lookup_field="uuid",
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text("documenten.ObjectInformatieObject",
                                "informatieobject"),
    )
    object = LengthHyperlinkedRelatedField(
        min_length=1,
        max_length=1000,
        view_name="",
        queryset=QuerySet(),
        lookup_field="uuid",
        help_text=
        _("URL-referentie naar het gerelateerde OBJECT (in deze of een andere API)."
          ),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = ("url", "informatieobject", "object", "object_type")
        extra_kwargs = {"url": {"lookup_field": "uuid"}}

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        value_display_mapping = add_choice_values_help_text(ObjectTypes)
        self.fields["object_type"].help_text += f"\n\n{value_display_mapping}"

    def set_object_properties(self, object_type):
        object_field = self.fields["object"]
        if object_type == "besluit":
            object_field.view_name = "besluit-detail"
            object_field.queryset = Besluit.objects
        else:
            object_field.view_name = "zaak-detail"
            object_field.queryset = Zaak.objects

    def to_internal_value(self, data):
        object_type = data["object_type"]
        self.set_object_properties(object_type)
        res = super().to_internal_value(data)
        return res

    def to_representation(self, instance):
        object_type = instance.object_type
        self.set_object_properties(object_type)
        return super().to_representation(instance)
Beispiel #17
0
class ZaakInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    aard_relatie_weergave = serializers.ChoiceField(
        source="get_aard_relatie_display",
        read_only=True,
        choices=[(force_text(value), key)
                 for key, value in RelatieAarden.choices],
    )
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name="enkelvoudiginformatieobject-detail",
        lookup_field="uuid",
        queryset=EnkelvoudigInformatieObject.objects.all(),
        min_length=1,
        max_length=1000,
        help_text=get_help_text("documenten.Gebruiksrechten",
                                "informatieobject"),
        validators=[IsImmutableValidator()],
    )

    class Meta:
        model = ZaakInformatieObject
        fields = (
            "url",
            "uuid",
            "informatieobject",
            "zaak",
            "aard_relatie_weergave",
            "titel",
            "beschrijving",
            "registratiedatum",
        )
        validators = [
            UniqueTogetherValidator(
                queryset=ZaakInformatieObject.objects.all(),
                fields=["zaak", "informatieobject"],
            ),
            ZaaktypeInformatieobjecttypeRelationValidator(),
        ]
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "uuid": {
                "read_only": True
            },
            "zaak": {
                "lookup_field": "uuid",
                "validators": [IsImmutableValidator()]
            },
        }
Beispiel #18
0
 class Meta:
     model = Rol
     fields = (
         "url",
         "uuid",
         "zaak",
         "betrokkene",
         "betrokkene_type",
         "roltype",
         "omschrijving",
         "omschrijving_generiek",
         "roltoelichting",
         "registratiedatum",
         "indicatie_machtiging",
     )
     validators = [
         RolOccurenceValidator(RolOmschrijving.initiator, max_amount=1),
         RolOccurenceValidator(RolOmschrijving.zaakcoordinator,
                               max_amount=1),
         CorrectZaaktypeValidator("roltype"),
     ]
     extra_kwargs = {
         "url": {
             "lookup_field": "uuid"
         },
         "uuid": {
             "read_only": True
         },
         "zaak": {
             "lookup_field": "uuid"
         },
         "betrokkene": {
             "required": False
         },
         "roltype": {
             "lookup_field":
             "uuid",
             "max_length":
             1000,
             "min_length":
             1,
             "validators": [
                 LooseFkResourceValidator("RolType", settings.ZTC_API_SPEC),
                 LooseFkIsImmutableValidator(),
             ],
             "help_text":
             get_help_text("zaken.Rol", "roltype"),
         },
     }
class GebruiksrechtenFilter(FilterSet):
    informatieobject = URLModelChoiceFilter(
        queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
        instance_path='canonical',
        help_text=get_help_text('datamodel.Gebruiksrechten',
                                'informatieobject'),
    )

    class Meta:
        model = Gebruiksrechten
        fields = {
            'informatieobject': ['exact'],
            'startdatum': ['lt', 'lte', 'gt', 'gte'],
            'einddatum': ['lt', 'lte', 'gt', 'gte'],
        }
Beispiel #20
0
class ObjectInformatieObjectFilter(FilterSet):
    informatieobject = URLModelChoiceFilter(
        queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
        instance_path="canonical",
        help_text=get_help_text("documenten.ObjectInformatieObject",
                                "informatieobject"),
    )
    object = ObjectFilter(
        queryset=object_queryset,
        help_text=
        _("URL-referentie naar het gerelateerde OBJECT (in deze of een andere API)."
          ),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = ("object", "informatieobject")
Beispiel #21
0
class ObjectInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name='enkelvoudiginformatieobject-detail',
        lookup_field='uuid',
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text('datamodel.ObjectInformatieObject', 'informatieobject'),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = (
            'url',
            'informatieobject',
            'object',
            'object_type',
        )
        extra_kwargs = {
            'url': {
                'lookup_field': 'uuid',
            },
            'informatieobject': {
                'validators': [IsImmutableValidator()],
            },
            'object': {
                'validators': [
                    URLValidator(get_auth=get_zrc_auth, headers={'Accept-Crs': 'EPSG:4326'}),
                    IsImmutableValidator(),
                ],
            },
            'object_type': {
                'validators': [IsImmutableValidator()]
            }
        }
        validators = [ObjectInformatieObjectValidator(), InformatieObjectUniqueValidator('object', 'informatieobject')]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        value_display_mapping = add_choice_values_help_text(ObjectTypes)
        self.fields['object_type'].help_text += f"\n\n{value_display_mapping}"

        if not hasattr(self, 'initial_data'):
            return
Beispiel #22
0
class ObjectInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name="enkelvoudiginformatieobject-detail",
        lookup_field="uuid",
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text("datamodel.ObjectInformatieObject",
                                "informatieobject"),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = ("url", "informatieobject", "object", "object_type")
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "informatieobject": {
                "validators": [IsImmutableValidator()]
            },
            "object": {
                "validators": [
                    URLValidator(get_auth=get_zrc_auth,
                                 headers={"Accept-Crs": "EPSG:4326"}),
                    IsImmutableValidator(),
                ]
            },
            "object_type": {
                "validators": [IsImmutableValidator()]
            },
        }
        validators = [
            ObjectInformatieObjectValidator(),
            InformatieObjectUniqueValidator("object", "informatieobject"),
        ]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        value_display_mapping = add_choice_values_help_text(ObjectTypes)
        self.fields["object_type"].help_text += f"\n\n{value_display_mapping}"

        if not hasattr(self, "initial_data"):
            return
Beispiel #23
0
class ZaakEigenschapSerializer(NestedHyperlinkedModelSerializer):
    parent_lookup_kwargs = {"zaak_uuid": "zaak__uuid"}

    eigenschap = LengthHyperlinkedRelatedField(
        view_name="eigenschap-detail",
        lookup_field="uuid",
        queryset=Eigenschap.objects.all(),
        max_length=1000,
        min_length=1,
        help_text=get_help_text("zaken.ZaakEigenschap", "eigenschap"),
    )

    class Meta:
        model = ZaakEigenschap
        fields = ("url", "uuid", "zaak", "eigenschap", "naam", "waarde")
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "uuid": {
                "read_only": True
            },
            "zaak": {
                "lookup_field": "uuid"
            },
            "naam": {
                "source": "_naam",
                "read_only": True
            },
        }

    def validate(self, attrs):
        super().validate(attrs)

        eigenschap = attrs["eigenschap"]
        attrs["_naam"] = eigenschap.eigenschapnaam

        return attrs
Beispiel #24
0
class KlantFilter(FilterSet):
    subject_natuurlijk_persoon__inp_bsn = filters.CharFilter(
        field_name="natuurlijk_persoon__inp_bsn",
        help_text=get_help_text("datamodel.NatuurlijkPersoon", "inp_bsn"),
    )
    subject_natuurlijk_persoon__anp_identificatie = filters.CharFilter(
        field_name="natuurlijk_persoon__anp_identificatie",
        help_text=get_help_text("datamodel.NatuurlijkPersoon", "anp_identificatie"),
    )
    subject_natuurlijk_persoon__inp_a_nummer = filters.CharFilter(
        field_name="natuurlijk_persoon__inp_a_nummer",
        help_text=get_help_text("datamodel.NatuurlijkPersoon", "inp_a_nummer"),
    )
    subject_niet_natuurlijk_persoon__inn_nnp_id = filters.CharFilter(
        field_name="niet_natuurlijk_persoon__inn_nnp_id",
        help_text=get_help_text("datamodel.NietNatuurlijkPersoon", "inn_nnp_id"),
    )
    subject_niet_natuurlijk_persoon__ann_identificatie = filters.CharFilter(
        field_name="niet_natuurlijk_persoon__ann_identificatie",
        help_text=get_help_text("datamodel.NietNatuurlijkPersoon", "ann_identificatie"),
    )
    subject_vestiging__vestigings_nummer = filters.CharFilter(
        field_name="vestiging__vestigings_nummer",
        help_text=get_help_text("datamodel.Vestiging", "vestigings_nummer"),
    )

    class Meta:
        model = Klant
        fields = {
            "bronorganisatie": ["exact"],
            "klantnummer": ["exact"],
            "bedrijfsnaam": ["exact"],
            "functie": ["exact"],
            "achternaam": ["exact"],
            "telefoonnummer": ["exact"],
            "emailadres": ["exact"],
            "adres__straatnaam": ["exact"],
            "adres__postcode": ["exact"],
            "adres__woonplaats_naam": ["exact"],
            "adres__landcode": ["exact"],
            "subject": ["exact"],
            "subject_type": ["exact"],
        }
Beispiel #25
0
class BesluitInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectField(
        validators=[
            LooseFkIsImmutableValidator(instance_path="canonical"),
            LooseFkResourceValidator(
                "EnkelvoudigInformatieObject", settings.DRC_API_SPEC
            ),
        ],
        max_length=1000,
        min_length=1,
        help_text=get_help_text(
            "besluiten.BesluitInformatieObject", "informatieobject"
        ),
    )

    class Meta:
        model = BesluitInformatieObject
        fields = ("url", "informatieobject", "besluit")
        validators = [
            UniqueTogetherValidator(
                queryset=BesluitInformatieObject.objects.all(),
                fields=["besluit", "informatieobject"],
            ),
            ObjecttypeInformatieobjecttypeRelationValidator("besluit", "besluittype"),
        ]
        extra_kwargs = {
            "url": {"lookup_field": "uuid"},
            "besluit": {"lookup_field": "uuid", "validators": [IsImmutableValidator()]},
        }

    def create(self, validated_data):
        with transaction.atomic():
            bio = super().create(validated_data)

        # local FK or CMIS - nothing to do -> our signals create the OIO
        if bio.informatieobject.pk or settings.CMIS_ENABLED:
            return bio

        # we know that we got valid URLs in the initial data
        io_url = self.initial_data["informatieobject"]
        besluit_url = self.initial_data["besluit"]

        # manual transaction management - documents API checks that the BIO
        # exists, so that transaction must be committed.
        # If it fails in any other way, we need to handle that by rolling back
        # the BIO creation.
        try:
            response = create_remote_oio(io_url, besluit_url, "besluit")
        except Exception as exception:
            bio.delete()
            raise serializers.ValidationError(
                {
                    "informatieobject": _(
                        "Could not create remote relation: {exception}"
                    ).format(exception=exception)
                },
                code="pending-relations",
            )
        else:
            bio._objectinformatieobject_url = response["url"]
            bio.save()
        return bio

    def run_validators(self, value):
        """
        Add read_only fields with defaults to value before running validators.
        """
        # In the case CMIS is enabled, we need to filter on the URL and not the canonical object
        if value.get("informatieobject") is not None and settings.CMIS_ENABLED:
            value["informatieobject"] = self.initial_data.get("informatieobject")

        return super().run_validators(value)
Beispiel #26
0
class RolSerializer(PolymorphicSerializer):
    roltype = LengthHyperlinkedRelatedField(
        view_name="roltype-detail",
        lookup_field="uuid",
        queryset=RolType.objects.all(),
        max_length=1000,
        min_length=1,
        validators=[IsImmutableValidator()],
        help_text=get_help_text("zaken.Rol", "roltype"),
    )
    discriminator = Discriminator(
        discriminator_field="betrokkene_type",
        mapping={
            RolTypes.natuurlijk_persoon:
            RolNatuurlijkPersoonSerializer(),
            RolTypes.niet_natuurlijk_persoon:
            RolNietNatuurlijkPersoonSerializer(),
            RolTypes.vestiging:
            RolVestigingSerializer(),
            RolTypes.organisatorische_eenheid:
            RolOrganisatorischeEenheidSerializer(),
            RolTypes.medewerker:
            RolMedewerkerSerializer(),
        },
        group_field="betrokkene_identificatie",
        same_model=False,
    )

    class Meta:
        model = Rol
        fields = (
            "url",
            "uuid",
            "zaak",
            "betrokkene",
            "betrokkene_type",
            "roltype",
            "omschrijving",
            "omschrijving_generiek",
            "roltoelichting",
            "registratiedatum",
            "indicatie_machtiging",
        )
        validators = [
            RolOccurenceValidator(RolOmschrijving.initiator, max_amount=1),
            RolOccurenceValidator(RolOmschrijving.zaakcoordinator,
                                  max_amount=1),
            CorrectZaaktypeValidator("roltype"),
        ]
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "uuid": {
                "read_only": True
            },
            "zaak": {
                "lookup_field": "uuid"
            },
            "betrokkene": {
                "required": False
            },
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        value_display_mapping = add_choice_values_help_text(
            IndicatieMachtiging)
        self.fields[
            "indicatie_machtiging"].help_text += f"\n\n{value_display_mapping}"

        value_display_mapping = add_choice_values_help_text(RolTypes)
        self.fields[
            "betrokkene_type"].help_text += f"\n\n{value_display_mapping}"

        value_display_mapping = add_choice_values_help_text(RolOmschrijving)
        self.fields[
            "omschrijving_generiek"].help_text += f"\n\n{value_display_mapping}"

    def validate(self, attrs):
        validated_attrs = super().validate(attrs)
        betrokkene = validated_attrs.get("betrokkene", None)
        betrokkene_identificatie = validated_attrs.get(
            "betrokkene_identificatie", None)

        if not betrokkene and not betrokkene_identificatie:
            raise serializers.ValidationError(
                _("betrokkene or betrokkeneIdentificatie must be provided"),
                code="invalid-betrokkene",
            )

        return validated_attrs

    @transaction.atomic
    def create(self, validated_data):
        group_data = validated_data.pop("betrokkene_identificatie", None)
        rol = super().create(validated_data)

        if group_data:
            group_serializer = self.discriminator.mapping[
                validated_data["betrokkene_type"]]
            serializer = group_serializer.get_fields(
            )["betrokkene_identificatie"]
            group_data["rol"] = rol
            serializer.create(group_data)

        return rol
Beispiel #27
0
class BesluitSerializer(serializers.HyperlinkedModelSerializer):
    besluittype = LengthHyperlinkedRelatedField(
        view_name="besluittype-detail",
        lookup_field="uuid",
        queryset=BesluitType.objects,
        max_length=200,
        min_length=1,
        help_text=get_help_text("besluiten.Besluit", "besluittype"),
    )
    zaak = LengthHyperlinkedRelatedField(
        view_name="zaak-detail",
        lookup_field="uuid",
        queryset=Zaak.objects,
        required=False,
        allow_null=True,
        max_length=200,
        help_text=get_help_text("besluiten.Besluit", "zaak"),
    )
    vervalreden_weergave = serializers.CharField(
        source="get_vervalreden_display", read_only=True)

    class Meta:
        model = Besluit
        fields = (
            "url",
            "identificatie",
            "verantwoordelijke_organisatie",
            "besluittype",
            "zaak",
            "datum",
            "toelichting",
            "bestuursorgaan",
            "ingangsdatum",
            "vervaldatum",
            "vervalreden",
            "vervalreden_weergave",
            "publicatiedatum",
            "verzenddatum",
            "uiterlijke_reactiedatum",
        )
        extra_kwargs = {
            "url": {
                "lookup_field": "uuid"
            },
            "identificatie": {
                "validators": [IsImmutableValidator()]
            },
            "verantwoordelijke_organisatie": {
                "validators": [IsImmutableValidator(), validate_rsin]
            },
        }
        validators = [
            UniekeIdentificatieValidator(),
            BesluittypeZaaktypeValidator()
        ]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        value_display_mapping = add_choice_values_help_text(VervalRedenen)
        self.fields["vervalreden"].help_text += f"\n\n{value_display_mapping}"
Beispiel #28
0
class ObjectInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
        view_name="enkelvoudiginformatieobject-detail",
        lookup_field="uuid",
        queryset=EnkelvoudigInformatieObject.objects,
        help_text=get_help_text(
            "documenten.ObjectInformatieObject", "informatieobject"
        ),
    )
    object = FKOrURLField(
        max_length=1000,
        min_length=1,
        help_text=_(
            "URL-referentie naar het gerelateerde OBJECT (in deze of een andere API)."
        ),
    )

    class Meta:
        model = ObjectInformatieObject
        fields = ("url", "informatieobject", "object", "object_type")
        extra_kwargs = {
            "url": {"lookup_field": "uuid"},
            "object": {"lookup_field": "uuid"},
        }
        validators = [InformatieObjectUniqueValidator()]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        value_display_mapping = add_choice_values_help_text(ObjectTypes)
        self.fields["object_type"].help_text += f"\n\n{value_display_mapping}"

    def set_object_properties(self, object_type: str) -> None:
        object_field = self.fields["object"]

        if object_type == ObjectTypes.besluit:
            object_field.source = "besluit"
            object_field.validators.append(
                LooseFkResourceValidator("Besluit", settings.BRC_API_SPEC)
            )
        elif object_type == ObjectTypes.zaak:
            object_field.source = "zaak"
            object_field.validators.append(
                LooseFkResourceValidator("Zaak", settings.ZRC_API_SPEC)
            )

    def to_internal_value(self, data):
        object_type = data["object_type"]
        # validate that it's a valid object type first
        try:
            self.fields["object_type"].run_validation(object_type)
        except serializers.ValidationError as exc:
            raise serializers.ValidationError({"object_type": exc.detail})

        self.set_object_properties(object_type)
        res = super().to_internal_value(data)
        if settings.CMIS_ENABLED:
            # res contains the canonical object instead of the document url, but if only the
            # canonical object is given, the document cannot be retrieved from Alfresco
            res["informatieobject"] = data["informatieobject"]
        return res

    def to_representation(self, instance):
        object_type = instance.object_type
        self.set_object_properties(object_type)
        ret = super().to_representation(instance)
        if settings.CMIS_ENABLED:
            # Objects without a primary key will have 'None' as the URL, so it is added manually
            path = reverse(
                "objectinformatieobject-detail",
                kwargs={"version": 1, "uuid": instance.uuid},
            )
            ret["url"] = make_absolute_uri(path, request=self.context.get("request"))
            ret["informatieobject"] = instance.get_informatieobject_url()

        return ret

    def create(self, validated_data):
        object_type = validated_data["object_type"]
        validated_data[object_type] = validated_data.pop("object")

        oio = super().create(validated_data)
        return oio
class ProductSerializer(serializers.Serializer):
    code = serializers.CharField(
        max_length=20,
        source="product_code",
        help_text=get_help_text("datamodel.VerzoekProduct", "product_code"),
    )
Beispiel #30
0
class ZaakInformatieObjectSerializer(serializers.HyperlinkedModelSerializer):
    aard_relatie_weergave = serializers.ChoiceField(
        source="get_aard_relatie_display",
        read_only=True,
        choices=[(force_text(value), key) for key, value in RelatieAarden.choices],
    )
    informatieobject = EnkelvoudigInformatieObjectField(
        validators=[
            LooseFkIsImmutableValidator(instance_path="canonical"),
            LooseFkResourceValidator(
                "EnkelvoudigInformatieObject", settings.DRC_API_SPEC
            ),
        ],
        max_length=1000,
        min_length=1,
        help_text=get_help_text("zaken.ZaakInformatieObject", "informatieobject"),
    )

    class Meta:
        model = ZaakInformatieObject
        fields = (
            "url",
            "uuid",
            "informatieobject",
            "zaak",
            "aard_relatie_weergave",
            "titel",
            "beschrijving",
            "registratiedatum",
        )
        validators = [
            UniqueTogetherValidator(
                queryset=ZaakInformatieObject.objects.all(),
                fields=["zaak", "informatieobject"],
            ),
            ObjecttypeInformatieobjecttypeRelationValidator(),
        ]
        extra_kwargs = {
            "url": {"lookup_field": "uuid"},
            "uuid": {"read_only": True},
            "zaak": {"lookup_field": "uuid", "validators": [IsImmutableValidator()]},
        }

    def create(self, validated_data):
        with transaction.atomic():
            zio = super().create(validated_data)

        # local FK - nothing to do -> our signals create the OIO
        if zio.informatieobject.pk:
            return zio

        # we know that we got valid URLs in the initial data
        io_url = self.initial_data["informatieobject"]
        zaak_url = self.initial_data["zaak"]

        # manual transaction management - documents API checks that the ZIO
        # exists, so that transaction must be committed.
        # If it fails in any other way, we need to handle that by rolling back
        # the ZIO creation.
        try:
            response = create_remote_oio(io_url, zaak_url)
        except Exception as exception:
            zio.delete()
            raise serializers.ValidationError(
                {
                    "informatieobject": _(
                        "Could not create remote relation: {exception}"
                    ).format(exception)
                },
                code="pending-relations",
            )
        else:
            zio._objectinformatieobject_url = response["url"]
            zio.save()

        return zio