Skip to content

Commit

Permalink
Merge pull request #1546 from open-zaak/feature/1545-eio-trefwoorden
Browse files Browse the repository at this point in the history
Feature/1545 eio trefwoorden
  • Loading branch information
annashamray committed Feb 1, 2024
2 parents 11e53ae + 8ce2d12 commit 8b1d48f
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/openzaak/components/autorisaties/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
# Copyright (C) 2019 - 2020 Dimpact
from django.utils.translation import ugettext_lazy as _

from django_filters.rest_framework import filters
from vng_api_common.authorizations.models import Applicatie
from vng_api_common.filtersets import FilterSet


class CharArrayFilter(filters.BaseInFilter, filters.CharFilter):
pass
from openzaak.utils.filters import CharArrayFilter


class ApplicatieFilter(FilterSet):
Expand Down
6 changes: 2 additions & 4 deletions src/openzaak/components/catalogi/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from vng_api_common.filtersets import FilterSet
from vng_api_common.utils import get_help_text, get_resource_for_path

from openzaak.utils.filters import CharArrayFilter

from ..models import (
BesluitType,
Catalogus,
Expand Down Expand Up @@ -67,10 +69,6 @@ def geldigheid_filter(queryset, name, value):
)


class CharArrayFilter(filters.BaseInFilter, filters.CharFilter):
pass


class RolTypeFilter(FilterSet):
status = filters.ChoiceFilter(
field_name="zaaktype__concept",
Expand Down
1 change: 1 addition & 0 deletions src/openzaak/components/documenten/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ class EnkelvoudigInformatieObjectAdmin(
"link",
"indicatie_gebruiksrecht",
"verschijningsvorm",
"trefwoorden",
)
},
),
Expand Down
5 changes: 3 additions & 2 deletions src/openzaak/components/documenten/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from vng_api_common.filtersets import FilterSet
from vng_api_common.utils import get_help_text

from openzaak.utils.filters import ExpandFilter
from openzaak.utils.filters import CharArrayFilter, ExpandFilter

from ..models import (
EnkelvoudigInformatieObject,
Expand All @@ -31,11 +31,12 @@


class EnkelvoudigInformatieObjectListFilter(FilterSet):
trefwoorden = CharArrayFilter(field_name="trefwoorden", lookup_expr="contains")
expand = ExpandFilter(serializer_class=EnkelvoudigInformatieObjectSerializer)

class Meta:
model = EnkelvoudigInformatieObject
fields = ("identificatie", "bronorganisatie")
fields = ("identificatie", "bronorganisatie", "trefwoorden")


class EnkelvoudigInformatieObjectDetailFilter(FilterSet):
Expand Down
1 change: 1 addition & 0 deletions src/openzaak/components/documenten/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class Meta:
"informatieobjecttype", # van-relatie,
"locked",
"bestandsdelen",
"trefwoorden",
)
extra_kwargs = {
"taal": {"min_length": 3},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: EUPL-1.2
# Copyright (C) 2024 Dimpact
# Generated by Django 3.2.23 on 2024-01-22 14:39

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("documenten", "0030_enkelvoudiginformatieobject_verschijningsvorm"),
]

operations = [
migrations.AddField(
model_name="enkelvoudiginformatieobject",
name="trefwoorden",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=100, verbose_name="trefwoord"),
blank=True,
db_index=True,
default=list,
help_text="Een lijst van trefwoorden gescheiden door comma's.",
size=None,
),
),
]
9 changes: 9 additions & 0 deletions src/openzaak/components/documenten/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import urlparse

from django.conf import settings
from django.contrib.postgres.fields import ArrayField
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models, transaction
from django.db.models import Q
Expand Down Expand Up @@ -417,6 +418,14 @@ class EnkelvoudigInformatieObject(
help_text=_("De essentiële opmaakaspecten van een INFORMATIEOBJECT."),
)

trefwoorden = ArrayField(
models.CharField(_("trefwoord"), max_length=100),
blank=True,
default=list,
help_text=_("Een lijst van trefwoorden gescheiden door comma's."),
db_index=True,
)

# When dealing with remote EIO, there is no pk or canonical instance to derive
# the lock status from. The getters and setters then use this private attribute.
_locked = False
Expand Down
48 changes: 48 additions & 0 deletions src/openzaak/components/documenten/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ paths:
required: false
schema:
type: string
- name: trefwoorden
in: query
description: Multiple values may be separated by commas.
required: false
schema:
type: array
items:
type: string
style: form
explode: false
- name: expand
in: query
description: 'Sluit de gespecifieerde gerelateerde resources in in het antwoord. '
Expand Down Expand Up @@ -3159,6 +3169,14 @@ components:
items:
$ref: '#/components/schemas/BestandsDeel'
readOnly: true
trefwoorden:
description: Een lijst van trefwoorden gescheiden door comma's.
type: array
items:
title: Trefwoord
type: string
maxLength: 100
minLength: 1
EnkelvoudigInformatieObjectCreateLockData:
required:
- bronorganisatie
Expand Down Expand Up @@ -3385,6 +3403,14 @@ components:
items:
$ref: '#/components/schemas/BestandsDeel'
readOnly: true
trefwoorden:
description: Een lijst van trefwoorden gescheiden door comma's.
type: array
items:
title: Trefwoord
type: string
maxLength: 100
minLength: 1
lock:
title: Lock
description: Het gegenereerde lock ID voor grote bestandsuploads wat gebruikt
Expand Down Expand Up @@ -3417,6 +3443,12 @@ components:
\ eerste in een samenwerkingsketen heeft vastgelegd."
type: string
minLength: 1
trefwoorden:
description: Multiple values may be separated by commas.
type: array
items:
type: string
nullable: true
expand:
title: Expand
description: "Sluit de gespecifieerde gerelateerde resources in in het antwoord.\
Expand Down Expand Up @@ -3650,6 +3682,14 @@ components:
items:
$ref: '#/components/schemas/BestandsDeel'
readOnly: true
trefwoorden:
description: Een lijst van trefwoorden gescheiden door comma's.
type: array
items:
title: Trefwoord
type: string
maxLength: 100
minLength: 1
Wijzigingen:
type: object
properties:
Expand Down Expand Up @@ -4038,6 +4078,14 @@ components:
items:
$ref: '#/components/schemas/BestandsDeel'
readOnly: true
trefwoorden:
description: Een lijst van trefwoorden gescheiden door comma's.
type: array
items:
title: Trefwoord
type: string
maxLength: 100
minLength: 1
lock:
title: Lock
description: Tijdens het updaten van een document (PATCH, PUT) moet het
Expand Down
1 change: 1 addition & 0 deletions src/openzaak/components/documenten/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Uitleg bij mogelijke waarden:
| informatieobjecttype | URL-referentie naar het INFORMATIEOBJECTTYPE (in de Catalogi API). | string | ja | C​R​U​D |
| locked | Geeft aan of het document gelocked is. Alleen als een document gelocked is, mogen er aanpassingen gemaakt worden. | boolean | nee | ~~C~~​R​~~U~~~~D~~ |
| bestandsdelen | | array | nee | ~~C~~​R​~~U~~~~D~~ |
| trefwoorden | Een lijst van trefwoorden gescheiden door comma's. | array | nee | C​R​U​D |

## AuditTrail

Expand Down
63 changes: 63 additions & 0 deletions src/openzaak/components/documenten/swagger2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@
"required": false,
"type": "string"
},
{
"name": "trefwoorden",
"in": "query",
"description": "Multiple values may be separated by commas.",
"required": false,
"type": "array",
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"style": "form",
"explode": false
},
{
"name": "expand",
"in": "query",
Expand Down Expand Up @@ -3859,6 +3874,16 @@
"$ref": "#/definitions/BestandsDeel"
},
"readOnly": true
},
"trefwoorden": {
"description": "Een lijst van trefwoorden gescheiden door comma's.",
"type": "array",
"items": {
"title": "Trefwoord",
"type": "string",
"maxLength": 100,
"minLength": 1
}
}
}
},
Expand Down Expand Up @@ -4052,6 +4077,16 @@
},
"readOnly": true
},
"trefwoorden": {
"description": "Een lijst van trefwoorden gescheiden door comma's.",
"type": "array",
"items": {
"title": "Trefwoord",
"type": "string",
"maxLength": 100,
"minLength": 1
}
},
"lock": {
"title": "Lock",
"description": "Het gegenereerde lock ID voor grote bestandsuploads wat gebruikt moet worden bij document updates. Documenten met base64-encoded bestandsdata worden zonder lock aangemaakt.",
Expand Down Expand Up @@ -4087,6 +4122,14 @@
"type": "string",
"minLength": 1
},
"trefwoorden": {
"description": "Multiple values may be separated by commas.",
"type": "array",
"items": {
"type": "string",
"x-nullable": true
}
},
"expand": {
"title": "Expand",
"description": "Sluit de gespecifieerde gerelateerde resources in in het antwoord. \n\nUitleg bij mogelijke waarden:\n\n* `informatieobjecttype` - informatieobjecttype",
Expand Down Expand Up @@ -4286,6 +4329,16 @@
"$ref": "#/definitions/BestandsDeel"
},
"readOnly": true
},
"trefwoorden": {
"description": "Een lijst van trefwoorden gescheiden door comma's.",
"type": "array",
"items": {
"title": "Trefwoord",
"type": "string",
"maxLength": 100,
"minLength": 1
}
}
}
},
Expand Down Expand Up @@ -4621,6 +4674,16 @@
},
"readOnly": true
},
"trefwoorden": {
"description": "Een lijst van trefwoorden gescheiden door comma's.",
"type": "array",
"items": {
"title": "Trefwoord",
"type": "string",
"maxLength": 100,
"minLength": 1
}
},
"lock": {
"title": "Lock",
"description": "Tijdens het updaten van een document (PATCH, PUT) moet het `lock` veld opgegeven worden. Bij het aanmaken (POST) mag het geen waarde hebben.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_create(self):
"informatieobjecttype": f"http://testserver{informatieobjecttype_url}",
"vertrouwelijkheidaanduiding": "openbaar",
"verschijningsvorm": "Vorm A",
"trefwoorden": ["some", "other"],
}

# Send to the API
Expand Down Expand Up @@ -89,6 +90,7 @@ def test_create(self):
self.assertEqual(stored_object.informatieobjecttype, informatieobjecttype)
self.assertEqual(stored_object.vertrouwelijkheidaanduiding, "openbaar")
self.assertEqual(stored_object.verschijningsvorm, "Vorm A")
self.assertEqual(stored_object.trefwoorden, ["some", "other"])

expected_url = reverse(stored_object)
expected_file_url = get_operation_url(
Expand Down Expand Up @@ -263,6 +265,7 @@ def test_read(self):
"informatieobjecttype": f"http://testserver{reverse(test_object.informatieobjecttype)}",
"locked": False,
"verschijningsvorm": "",
"trefwoorden": [],
}

response_data = response.json()
Expand Down Expand Up @@ -1072,3 +1075,16 @@ def test_retrieve_expand(self):
}

self.assertEqual(data, expected_results)

def test_trefwoorden(self):
eio = EnkelvoudigInformatieObjectFactory.create(trefwoorden=["some", "other"])
EnkelvoudigInformatieObjectFactory.create(trefwoorden=[])
EnkelvoudigInformatieObjectFactory.create(trefwoorden=["dummy"])

response = self.client.get(self.url, {"trefwoorden": "some"})

self.assertEqual(response.status_code, status.HTTP_200_OK)

data = response.json()["results"]
self.assertEqual(len(data), 1)
self.assertEqual(data[0]["url"], f"http://testserver{reverse(eio)}")
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def test_create(self):
"locked": False,
"lock": "",
"verschijningsvorm": "",
"trefwoorden": [],
}
)

Expand Down Expand Up @@ -306,6 +307,7 @@ def test_read(self):
"informatieobjecttype": f"http://testserver{reverse(test_object.informatieobjecttype)}",
"locked": False,
"verschijningsvorm": "",
"trefwoorden": [],
}

response_data = response.json()
Expand Down
4 changes: 4 additions & 0 deletions src/openzaak/utils/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from .expansion import get_expand_options_for_serializer


class CharArrayFilter(filters.BaseInFilter, filters.CharFilter):
pass


class MaximaleVertrouwelijkheidaanduidingFilter(filters.ChoiceFilter):
def __init__(self, *args, **kwargs):
kwargs.setdefault("choices", VertrouwelijkheidsAanduiding.choices)
Expand Down

0 comments on commit 8b1d48f

Please sign in to comment.