Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Nov 14, 2024
1 parent 44a4032 commit 76d3331
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 56 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
Change history
==============

2.0.0 (2024-11-??)
------------------

* upgrade to zgw-consumers 0.35.1
* remove zds-client dependency

.. warning::

The ``APICredential`` class has been removed in favor of the ``Service`` model from zgw-consumers

.. warning::

Several notifications related models (``NotificationsConfig`` and ``Subscription``) as well as
the constants ``SCOPE_NOTIFICATIES_CONSUMEREN_LABEL`` and ``SCOPE_NOTIFICATIES_PUBLICEREN_LABEL`` have
been removed, since they are defined in ``notifications-api-common`` and were a not deleted yet in ``commonground-api-common``

1.13.4 (2024-10-25)
-------------------

Expand Down
3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ Features
* ``UniekeIdentificatieValidator`` (in combinatie met organisatie)
* ``InformatieObjectUniqueValidator`` om te valideren dat M2M entries
slechts eenmalig voorkomen
* ``ObjectInformatieObjectValidator`` om te valideren dat de synchronisatie
van een object-informatieobject relatie pas kan nadat deze relatie in het
DRC gemaakt is
* ``IsImmutableValidator`` - valideer dat bepaalde velden niet gewijzigd
worden bij een (partial) update, maar wel mogen gezet worden bij een create
* ``ResourceValidator`` - valideer dat een URL een bepaalde resource ontsluit
Expand Down
4 changes: 2 additions & 2 deletions docs/ref/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Obtaining a client
Internally, the `APIClient`_ client is used to resolve remote API objects. To
allow the `APIClient`_ to correctly, e.g use correct credentials for authentication
, an `Service`_ instance is required with a matching `api_root`. This replaces
the previous mechanism to use `APICredentials` for this purpose. A data migration
will be performed to migrate `APICredentials` to the `Service`_ model.
the previous mechanism to use `APICredentials` for this purpose. A transition from `APICredentials` to
the `Service`_ model is performed automatically with the data migration.


.. _APIClient: https://ape-pie.readthedocs.io/en/stable/reference.html#apiclient-class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.15 on 2024-11-14 13:30

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("zgw_consumers", "0022_set_default_service_slug"),
("authorizations", "0016_remove_authorizationsconfig_api_root_and_more"),
]

operations = [
migrations.AlterField(
model_name="authorizationsconfig",
name="authorizations_api_service",
field=models.ForeignKey(
limit_choices_to={"api_type": "ac", "auth_type": "zgw"},
on_delete=django.db.models.deletion.PROTECT,
to="zgw_consumers.service",
verbose_name="autorisations api service",
),
),
]
4 changes: 1 addition & 3 deletions vng_api_common/authorizations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class AuthorizationsConfig(SingletonModel):
auth_type=AuthTypes.zgw,
),
verbose_name=_("autorisations api service"),
on_delete=models.SET_NULL,
blank=True,
null=True,
on_delete=models.PROTECT,
)

objects = AuthorizationsConfigManager()
Expand Down
3 changes: 0 additions & 3 deletions vng_api_common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
from django.utils.encoding import smart_str
from django.utils.module_loading import import_string

from requests import RequestException
from rest_framework.utils import formatting

from .client import get_client, to_internal_data

try:
from djangorestframework_camel_case.util import (
underscore_to_camel as _underscore_to_camel,
Expand Down
45 changes: 0 additions & 45 deletions vng_api_common/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _

import requests
from rest_framework import serializers, validators

from .client import get_client, to_internal_data
from .constants import RSIN_LENGTH
from .oas import fetcher, obj_has_shape

Expand Down Expand Up @@ -221,49 +219,6 @@ def __call__(self, informatieobject: str, serializer):
super().__call__(attrs)


class ObjectInformatieObjectValidator:
"""
Validate that the INFORMATIEOBJECT is linked already in the DRC.
"""

message = _(
"Het informatieobject is in het DRC nog niet gerelateerd aan dit object."
)
code = "inconsistent-relation"
requires_context = True

def __call__(self, informatieobject: str, serializer):
object_url = serializer.context["parent_object"].get_absolute_api_url(
self.request
)

# dynamic so that it can be mocked in tests easily
client = get_client(informatieobject)

if not client:
raise ValidationError(
_("Geen service geconfigureerd voor %s") % informatieobject
)

try:
response = client.get(
"objectinformatieobject",
params={
"informatieobject": informatieobject,
"object": object_url,
},
)

oios = to_internal_data(response)
except (requests.RequestException, RuntimeError) as exc:
raise serializers.ValidationError(
exc.args[0], code="relation-validation-error"
) from exc

if len(oios) == 0:
raise serializers.ValidationError(self.message, code=self.code)


@deconstructible
class UntilNowValidator:
"""
Expand Down

0 comments on commit 76d3331

Please sign in to comment.