Skip to content

Commit

Permalink
Merge pull request #1470 from open-zaak/feature/1457-zaakobject-zaako…
Browse files Browse the repository at this point in the history
…bjecttype

Feature/1457 zaakobject zaakobjecttype
  • Loading branch information
annashamray committed Oct 23, 2023
2 parents 20c10ac + 52e95ba commit d447d14
Show file tree
Hide file tree
Showing 20 changed files with 9,457 additions and 3,443 deletions.
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ elastic-apm==6.13.2
# via -r requirements/base.in
face==20.1.1
# via glom
faker==13.3.2
faker==19.11.0
# via zgw-consumers
flower==1.2.0
# via -r requirements/base.in
Expand Down Expand Up @@ -316,7 +316,7 @@ requests==2.28.1
# zgw-consumers
requests-cache==0.9.4
# via -r requirements/base.in
requests-mock==1.9.3
requests-mock==1.11.0
# via zgw-consumers
ruamel-yaml==0.17.21
# via drf-yasg
Expand Down Expand Up @@ -369,7 +369,7 @@ wrapt==1.14.1
# via
# deprecated
# elastic-apm
zgw-consumers==0.26.2
zgw-consumers==0.27.0
# via
# -r requirements/base.in
# notifications-api-common
Expand Down
6 changes: 3 additions & 3 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ face==20.1.1
# glom
factory-boy==3.2.1
# via -r requirements/test-tools.in
faker==13.3.2
faker==19.11.0
# via
# -r requirements/base.txt
# factory-boy
Expand Down Expand Up @@ -443,7 +443,7 @@ requests==2.28.1
# zgw-consumers
requests-cache==0.9.4
# via -r requirements/base.txt
requests-mock==1.9.3
requests-mock==1.11.0
# via
# -r requirements/base.txt
# -r requirements/test-tools.in
Expand Down Expand Up @@ -532,7 +532,7 @@ wrapt==1.14.1
# -r requirements/base.txt
# deprecated
# elastic-apm
zgw-consumers==0.26.2
zgw-consumers==0.27.0
# via
# -r requirements/base.txt
# notifications-api-common
Expand Down
6 changes: 3 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ face==20.1.1
# glom
factory-boy==3.2.1
# via -r requirements/ci.txt
faker==13.3.2
faker==19.11.0
# via
# -r requirements/ci.txt
# factory-boy
Expand Down Expand Up @@ -549,7 +549,7 @@ requests==2.28.1
# zgw-consumers
requests-cache==0.9.4
# via -r requirements/ci.txt
requests-mock==1.9.3
requests-mock==1.11.0
# via
# -r requirements/ci.txt
# zgw-consumers
Expand Down Expand Up @@ -698,7 +698,7 @@ wrapt==1.14.1
# -r requirements/ci.txt
# deprecated
# elastic-apm
zgw-consumers==0.26.2
zgw-consumers==0.27.0
# via
# -r requirements/ci.txt
# notifications-api-common
Expand Down
3 changes: 3 additions & 0 deletions src/openzaak/components/besluiten/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def get_besluittype_response(catalogus: str, besluittype: str) -> dict:
"beginGeldigheid": "2018-01-01",
"eindeGeldigheid": None,
"concept": False,
"resultaattypen": [],
"resultaattypenOmschrijving": [],
"vastgelegdIn": [],
}


Expand Down
3 changes: 3 additions & 0 deletions src/openzaak/components/documenten/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def get_informatieobjecttype_response(
"vertrouwelijkheidaanduiding": "openbaar",
"beginGeldigheid": "2019-11-18",
"concept": False,
"zaaktypen": [],
"besluittypen": [],
"informatieobjectcategorie": "some category",
}


Expand Down
2 changes: 1 addition & 1 deletion src/openzaak/components/zaken/admin/zaken.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ZaakObjectAdmin(AuditTrailAdminMixin, UUIDAdminMixin, admin.ModelAdmin):
"zaak__uuid",
)
ordering = ("object_type", "object")
raw_id_fields = ("zaak",)
raw_id_fields = ("zaak", "_zaakobjecttype_base_url", "_zaakobjecttype")
viewset = "openzaak.components.zaken.api.viewsets.ZaakObjectViewSet"
inlines = [
AdresInline,
Expand Down
20 changes: 20 additions & 0 deletions src/openzaak/components/zaken/api/serializers/zaakobjecten.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: EUPL-1.2
# Copyright (C) 2019 - 2020 Dimpact
from django.conf import settings
from django.db import transaction
from django.utils.translation import ugettext_lazy as _

Expand All @@ -10,9 +11,14 @@
from vng_api_common.validators import IsImmutableValidator, URLValidator

from openzaak.utils.auth import get_auth
from openzaak.utils.validators import (
LooseFkIsImmutableValidator,
LooseFkResourceValidator,
)

from ...models import ZaakObject
from ..validators import (
CorrectZaaktypeValidator,
EitherFieldRequiredValidator,
JQExpressionValidator,
ObjectTypeOverigeDefinitieValidator,
Expand Down Expand Up @@ -154,6 +160,7 @@ class Meta:
"uuid",
"zaak",
"object",
"zaakobjecttype",
"object_type",
"object_type_overige",
"object_type_overige_definitie",
Expand All @@ -168,6 +175,18 @@ class Meta:
"validators": [URLValidator(get_auth=get_auth), IsImmutableValidator()],
},
"object_type": {"validators": [IsImmutableValidator()],},
"zaakobjecttype": {
"lookup_field": "uuid",
"max_length": 1000,
"allow_null": False,
"allow_blank": True,
"validators": [
LooseFkResourceValidator(
"ZaakObjectType", settings.ZTC_API_STANDARD
),
LooseFkIsImmutableValidator(),
],
},
}
validators = [
EitherFieldRequiredValidator(
Expand All @@ -178,6 +197,7 @@ class Meta:
),
ObjectTypeOverigeDefinitieValidator(),
ZaakArchiefStatusValidator(),
CorrectZaaktypeValidator("zaakobjecttype"),
]

def get_fields(self):
Expand Down
104 changes: 104 additions & 0 deletions src/openzaak/components/zaken/migrations/0029_auto_20230911_0810.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# SPDX-License-Identifier: EUPL-1.2
# Copyright (C) 2023 Dimpact
# Generated by Django 3.2.18 on 2023-09-11 08:10

from django.db import migrations, models
import django.db.models.deletion
import openzaak.utils.fields
import zgw_consumers.models.fields


class Migration(migrations.Migration):

dependencies = [
("zgw_consumers", "0016_auto_20220818_1412"),
("catalogi", "0015_auto_20230908_1438"),
("zaken", "0028_alter_spoorbaandeel_type"),
]

operations = [
migrations.AddField(
model_name="zaakobject",
name="_zaakobjecttype",
field=models.ForeignKey(
blank=True,
help_text="URL-referentie naar het ZAAKOBJECTTYPE (in de lokale Catalogi API).",
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="catalogi.zaakobjecttype",
),
),
migrations.AddField(
model_name="zaakobject",
name="_zaakobjecttype_base_url",
field=openzaak.utils.fields.ServiceFkField(
blank=True,
help_text="Basis deel van URL-referentie naar extern ZAAKOBJECTTYPE (in een andere Catalogi API).",
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="zgw_consumers.service",
),
),
migrations.AddField(
model_name="zaakobject",
name="_zaakobjecttype_relative_url",
field=openzaak.utils.fields.RelativeURLField(
blank=True,
help_text="Relatief deel van URL-referentie naar extern ZAAKOBJECTTYPE (in een andere Catalogi API).",
max_length=1000,
null=True,
verbose_name="zaakobjecttype relative url",
),
),
migrations.AddField(
model_name="zaakobject",
name="_zaakobjecttype_url",
field=zgw_consumers.models.fields.ServiceUrlField(
base_field="_zaakobjecttype_base_url",
blank=True,
null=True,
relative_field="_zaakobjecttype_relative_url",
),
),
migrations.AddField(
model_name="zaakobject",
name="zaakobjecttype",
field=openzaak.utils.fields.FkOrServiceUrlField(
blank=True,
fk_field="_zaakobjecttype",
null=True,
url_field="_zaakobjecttype_url",
),
),
migrations.AddConstraint(
model_name="zaakobject",
constraint=models.CheckConstraint(
check=models.Q(
models.Q(
("_zaakobjecttype_base_url__isnull", True),
models.Q(
("_zaakobjecttype_relative_url__isnull", True),
("_zaakobjecttype_relative_url", ""),
_connector="OR",
),
),
models.Q(
models.Q(
("_zaakobjecttype_base_url__isnull", True), _negated=True
),
models.Q(
models.Q(
("_zaakobjecttype_relative_url__isnull", True),
("_zaakobjecttype_relative_url", ""),
_connector="OR",
),
_negated=True,
),
),
_connector="OR",
),
name="zaken_zaakobject__zaakobjecttype_base_url_and__zaakobjecttype_relative_url_filled",
),
),
]
35 changes: 35 additions & 0 deletions src/openzaak/components/zaken/models/zaken.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,41 @@ class ZaakObject(models.Model):
'waarde "overige" heeft.',
)

_zaakobjecttype_base_url = ServiceFkField(
help_text="Basis deel van URL-referentie naar extern ZAAKOBJECTTYPE (in een andere Catalogi API).",
)
_zaakobjecttype_relative_url = RelativeURLField(
_("zaakobjecttype relative url"),
blank=True,
null=True,
help_text="Relatief deel van URL-referentie naar extern ZAAKOBJECTTYPE (in een andere Catalogi API).",
)
_zaakobjecttype_url = ServiceUrlField(
base_field="_zaakobjecttype_base_url",
relative_field="_zaakobjecttype_relative_url",
verbose_name=_("extern zaakobjecttype"),
blank=True,
null=True,
max_length=1000,
help_text=_(
"URL-referentie naar extern ZAAKOBJECTTYPE (in een andere Catalogi API)."
),
)
_zaakobjecttype = models.ForeignKey(
"catalogi.ZaakObjectType",
on_delete=models.PROTECT,
help_text="URL-referentie naar het ZAAKOBJECTTYPE (in de lokale Catalogi API).",
null=True,
blank=True,
)
zaakobjecttype = FkOrServiceUrlField(
fk_field="_zaakobjecttype",
url_field="_zaakobjecttype_url",
blank=True,
null=True,
help_text=_("URL-referentie naar het ZAAKOBJECTTYPE (in de Catalogi API)."),
)

objects = ZaakRelatedQuerySet.as_manager()

class Meta:
Expand Down
6 changes: 6 additions & 0 deletions src/openzaak/components/zaken/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5708,6 +5708,12 @@ components:
type: string
format: uri
maxLength: 1000
zaakobjecttype:
title: Zaakobjecttype
description: URL-referentie naar het ZAAKOBJECTTYPE (in de Catalogi API).
type: string
format: uri
maxLength: 1000
objectType:
title: Object type
description: 'Beschrijft het type OBJECT gerelateerd aan de ZAAK. Als er
Expand Down
1 change: 1 addition & 0 deletions src/openzaak/components/zaken/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Objecttype op [GEMMA Online](https://www.gemmaonline.nl/index.php/Rgbz_1.0/doc/o
| uuid | Unieke resource identifier (UUID4) | string | nee | ~~C~~​R​~~U~~~~D~~ |
| zaak | URL-referentie naar de ZAAK. | string | ja | C​R​U​D |
| object | URL-referentie naar de resource die het OBJECT beschrijft. | string | nee | C​R​U​D |
| zaakobjecttype | URL-referentie naar het ZAAKOBJECTTYPE (in de Catalogi API). | string | nee | C​R​U​D |
| objectType | Beschrijft het type OBJECT gerelateerd aan de ZAAK. Als er geen passend type is, dan moet het type worden opgegeven onder `objectTypeOverige`.

Uitleg bij mogelijke waarden:
Expand Down
7 changes: 7 additions & 0 deletions src/openzaak/components/zaken/swagger2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -7143,6 +7143,13 @@
"format": "uri",
"maxLength": 1000
},
"zaakobjecttype": {
"title": "Zaakobjecttype",
"description": "URL-referentie naar het ZAAKOBJECTTYPE (in de Catalogi API).",
"type": "string",
"format": "uri",
"maxLength": 1000
},
"objectType": {
"title": "Object type",
"description": "Beschrijft het type OBJECT gerelateerd aan de ZAAK. Als er geen passend type is, dan moet het type worden opgegeven onder `objectTypeOverige`.\n\nUitleg bij mogelijke waarden:\n\n* `adres` - Adres\n* `besluit` - Besluit\n* `buurt` - Buurt\n* `enkelvoudig_document` - Enkelvoudig document\n* `gemeente` - Gemeente\n* `gemeentelijke_openbare_ruimte` - Gemeentelijke openbare ruimte\n* `huishouden` - Huishouden\n* `inrichtingselement` - Inrichtingselement\n* `kadastrale_onroerende_zaak` - Kadastrale onroerende zaak\n* `kunstwerkdeel` - Kunstwerkdeel\n* `maatschappelijke_activiteit` - Maatschappelijke activiteit\n* `medewerker` - Medewerker\n* `natuurlijk_persoon` - Natuurlijk persoon\n* `niet_natuurlijk_persoon` - Niet-natuurlijk persoon\n* `openbare_ruimte` - Openbare ruimte\n* `organisatorische_eenheid` - Organisatorische eenheid\n* `pand` - Pand\n* `spoorbaandeel` - Spoorbaandeel\n* `status` - Status\n* `terreindeel` - Terreindeel\n* `terrein_gebouwd_object` - Terrein gebouwd object\n* `vestiging` - Vestiging\n* `waterdeel` - Waterdeel\n* `wegdeel` - Wegdeel\n* `wijk` - Wijk\n* `woonplaats` - Woonplaats\n* `woz_deelobject` - Woz deel object\n* `woz_object` - Woz object\n* `woz_waarde` - Woz waarde\n* `zakelijk_recht` - Zakelijk recht\n* `overige` - Overige",
Expand Down
2 changes: 1 addition & 1 deletion src/openzaak/components/zaken/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Params:
)


class ZaakObjectFactory(factory.django.DjangoModelFactory):
class ZaakObjectFactory(FkOrServiceUrlFactoryMixin, factory.django.DjangoModelFactory):
zaak = factory.SubFactory(ZaakFactory)
object = factory.Faker("url")
# Excluded: overige
Expand Down
2 changes: 2 additions & 0 deletions src/openzaak/components/zaken/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def test_zet_adres_binnenland(self):
"objectTypeOverige": "",
"relatieomschrijving": "Het adres waar de overlast vastgesteld werd.",
"objectTypeOverigeDefinitie": None,
"zaakobjecttype": None,
},
)

Expand Down Expand Up @@ -262,6 +263,7 @@ def test_zet_stadsdeel(self):
"objectTypeOverige": "",
"relatieomschrijving": "Afgeleid gebied",
"objectTypeOverigeDefinitie": None,
"zaakobjecttype": None,
},
)

Expand Down

0 comments on commit d447d14

Please sign in to comment.