diff --git a/requirements/base.txt b/requirements/base.txt index cc6f074a..65daf192 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -16,6 +16,7 @@ boltons==21.0.0 # glom certifi==2020.12.5 # via + # django-simple-certmanager # elastic-apm # requests # sentry-sdk @@ -29,22 +30,20 @@ coreschema==0.0.4 # via # coreapi # drf-yasg -cryptography==3.4.8 +cryptography==41.0.7 # via + # django-simple-certmanager # josepy # mozilla-django-oidc # pyopenssl -django-admin-index==1.5.0 +django-admin-index==3.1.0 # via -r requirements/base.in -django-axes==5.14.0 +django-axes==5.41.1 # via -r requirements/base.in -django-better-admin-arrayfield==1.4.2 - # via mozilla-django-oidc-db django-choices==1.7.2 # via # -r requirements/base.in # vng-api-common - # zgw-consumers django-filter==2.4.0 # via # -r requirements/base.in @@ -53,23 +52,31 @@ django-formtools==2.3 # via maykin-django-two-factor-auth django-ipware==3.0.2 # via django-axes +django-jsonform==2.21.4 + # via mozilla-django-oidc-db django-markup==1.3 # via vng-api-common -django-ordered-model==3.4.1 +django-ordered-model==3.7.4 # via django-admin-index django-otp==1.0.6 # via maykin-django-two-factor-auth django-phonenumber-field==5.2.0 # via maykin-django-two-factor-auth +django-privates==2.0.0.post0 + # via django-simple-certmanager django-redis==5.2.0 # via -r requirements/base.in -django-relativedelta==1.1.2 +django-relativedelta==2.0.0 # via zgw-consumers django-rest-framework-condition==0.1.1 # via vng-api-common django-rosetta==0.9.8 # via -r requirements/base.in -django-solo==1.1.5 +django-sendfile2==0.7.0 + # via django-privates +django-simple-certmanager==1.4.1 + # via zgw-consumers +django-solo==2.2.0 # via # mozilla-django-oidc-db # vng-api-common @@ -77,17 +84,23 @@ django-solo==1.1.5 django==3.2.23 # via # -r requirements/base.in + # django-admin-index # django-axes # django-choices # django-filter # django-formtools + # django-jsonform # django-markup # django-otp # django-phonenumber-field + # django-privates # django-redis # django-relativedelta # django-rest-framework-condition # django-rosetta + # django-sendfile2 + # django-simple-certmanager + # django-solo # djangorestframework # drf-nested-routers # drf-spectacular @@ -99,7 +112,7 @@ django==3.2.23 # zgw-consumers djangorestframework-camel-case==1.2.0 # via vng-api-common -djangorestframework-gis==0.17 +djangorestframework-gis==1.0 # via -r requirements/base.in djangorestframework==3.12.4 # via @@ -121,7 +134,7 @@ face==20.1.1 # via glom faker==8.1.0 # via zgw-consumers -gemma-zds-client==1.0.0 +gemma-zds-client==1.0.1 # via # vng-api-common # zgw-consumers @@ -155,9 +168,9 @@ markupsafe==2.1.3 # via jinja2 maykin-django-two-factor-auth[phonenumbers]==2.0.3 # via -r requirements/base.in -mozilla-django-oidc-db==0.9.0 +mozilla-django-oidc-db==0.14.1 # via -r requirements/base.in -mozilla-django-oidc==1.2.4 +mozilla-django-oidc==4.0.0 # via mozilla-django-oidc-db oyaml==1.0 # via vng-api-common @@ -170,17 +183,18 @@ pillow==10.2.0 polib==1.1.1 # via django-rosetta psycopg2==2.8.6 - # via - # -r requirements/base.in - # mozilla-django-oidc-db + # via -r requirements/base.in pycparser==2.20 # via cffi pyjwt==2.4.0 # via # gemma-zds-client # vng-api-common -pyopenssl==20.0.1 - # via josepy +pyopenssl==23.3.0 + # via + # django-simple-certmanager + # josepy + # zgw-consumers pyrsistent==0.17.3 # via jsonschema python-dateutil==2.8.1 @@ -228,8 +242,6 @@ six==1.15.0 # django-markup # isodate # jsonschema - # mozilla-django-oidc - # pyopenssl # python-dateutil # qrcode # requests-mock @@ -253,7 +265,7 @@ uwsgi==2.0.21 # via -r requirements/base.in vng-api-common[markdown_docs]==1.8.0 # via -r requirements/base.in -zgw-consumers==0.15.2 +zgw-consumers==0.27.0 # via -r requirements/base.in # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/ci.txt b/requirements/ci.txt index 2783781e..4524c8da 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -23,6 +23,7 @@ boltons==21.0.0 certifi==2020.12.5 # via # -r requirements/base.txt + # django-simple-certmanager # elastic-apm # requests # sentry-sdk @@ -45,27 +46,23 @@ coreschema==0.0.4 # drf-yasg coverage==4.5.4 # via -r requirements/test-tools.in -cryptography==3.4.8 +cryptography==41.0.7 # via # -r requirements/base.txt + # django-simple-certmanager # josepy # mozilla-django-oidc # pyopenssl cssselect==1.1.0 # via pyquery -django-admin-index==1.5.0 +django-admin-index==3.1.0 # via -r requirements/base.txt -django-axes==5.14.0 +django-axes==5.41.1 # via -r requirements/base.txt -django-better-admin-arrayfield==1.4.2 - # via - # -r requirements/base.txt - # mozilla-django-oidc-db django-choices==1.7.2 # via # -r requirements/base.txt # vng-api-common - # zgw-consumers django-filter==2.4.0 # via # -r requirements/base.txt @@ -78,11 +75,15 @@ django-ipware==3.0.2 # via # -r requirements/base.txt # django-axes +django-jsonform==2.21.4 + # via + # -r requirements/base.txt + # mozilla-django-oidc-db django-markup==1.3 # via # -r requirements/base.txt # vng-api-common -django-ordered-model==3.4.1 +django-ordered-model==3.7.4 # via # -r requirements/base.txt # django-admin-index @@ -94,9 +95,13 @@ django-phonenumber-field==5.2.0 # via # -r requirements/base.txt # maykin-django-two-factor-auth +django-privates==2.0.0.post0 + # via + # -r requirements/base.txt + # django-simple-certmanager django-redis==5.2.0 # via -r requirements/base.txt -django-relativedelta==1.1.2 +django-relativedelta==2.0.0 # via # -r requirements/base.txt # zgw-consumers @@ -106,7 +111,15 @@ django-rest-framework-condition==0.1.1 # vng-api-common django-rosetta==0.9.8 # via -r requirements/base.txt -django-solo==1.1.5 +django-sendfile2==0.7.0 + # via + # -r requirements/base.txt + # django-privates +django-simple-certmanager==1.4.1 + # via + # -r requirements/base.txt + # zgw-consumers +django-solo==2.2.0 # via # -r requirements/base.txt # mozilla-django-oidc-db @@ -117,17 +130,23 @@ django-webtest==1.9.7 django==3.2.23 # via # -r requirements/base.txt + # django-admin-index # django-axes # django-choices # django-filter # django-formtools + # django-jsonform # django-markup # django-otp # django-phonenumber-field + # django-privates # django-redis # django-relativedelta # django-rest-framework-condition # django-rosetta + # django-sendfile2 + # django-simple-certmanager + # django-solo # djangorestframework # drf-nested-routers # drf-spectacular @@ -141,7 +160,7 @@ djangorestframework-camel-case==1.2.0 # via # -r requirements/base.txt # vng-api-common -djangorestframework-gis==0.17 +djangorestframework-gis==1.0 # via -r requirements/base.txt djangorestframework==3.12.4 # via @@ -176,7 +195,7 @@ faker==8.1.0 # zgw-consumers freezegun==1.1.0 # via -r requirements/test-tools.in -gemma-zds-client==1.0.0 +gemma-zds-client==1.0.1 # via # -r requirements/base.txt # vng-api-common @@ -230,9 +249,9 @@ markupsafe==2.1.3 # jinja2 maykin-django-two-factor-auth[phonenumbers]==2.0.3 # via -r requirements/base.txt -mozilla-django-oidc-db==0.9.0 +mozilla-django-oidc-db==0.14.1 # via -r requirements/base.txt -mozilla-django-oidc==1.2.4 +mozilla-django-oidc==4.0.0 # via # -r requirements/base.txt # mozilla-django-oidc-db @@ -255,9 +274,7 @@ polib==1.1.1 # -r requirements/base.txt # django-rosetta psycopg2==2.8.6 - # via - # -r requirements/base.txt - # mozilla-django-oidc-db + # via -r requirements/base.txt pycparser==2.20 # via # -r requirements/base.txt @@ -267,10 +284,12 @@ pyjwt==2.4.0 # -r requirements/base.txt # gemma-zds-client # vng-api-common -pyopenssl==20.0.1 +pyopenssl==23.3.0 # via # -r requirements/base.txt + # django-simple-certmanager # josepy + # zgw-consumers pyquery==1.4.3 # via -r requirements/test-tools.in pyrsistent==0.17.3 @@ -338,8 +357,6 @@ six==1.15.0 # django-markup # isodate # jsonschema - # mozilla-django-oidc - # pyopenssl # python-dateutil # qrcode # requests-mock @@ -382,7 +399,7 @@ webob==1.8.7 # via webtest webtest==2.0.35 # via django-webtest -zgw-consumers==0.15.2 +zgw-consumers==0.27.0 # via -r requirements/base.txt # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/dev.txt b/requirements/dev.txt index a1310e65..fcf6389d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -35,6 +35,7 @@ bumpversion==0.6.0 certifi==2020.12.5 # via # -r requirements/ci.txt + # django-simple-certmanager # elastic-apm # requests # sentry-sdk @@ -63,9 +64,10 @@ coreschema==0.0.4 # drf-yasg coverage==4.5.4 # via -r requirements/ci.txt -cryptography==3.4.8 +cryptography==41.0.7 # via # -r requirements/ci.txt + # django-simple-certmanager # josepy # mozilla-django-oidc # pyopenssl @@ -73,20 +75,15 @@ cssselect==1.1.0 # via # -r requirements/ci.txt # pyquery -django-admin-index==1.5.0 +django-admin-index==3.1.0 # via -r requirements/ci.txt -django-axes==5.14.0 +django-axes==5.41.1 # via -r requirements/ci.txt -django-better-admin-arrayfield==1.4.2 - # via - # -r requirements/ci.txt - # mozilla-django-oidc-db django-choices==1.7.2 # via # -r requirements/ci.txt # vng-api-common - # zgw-consumers -django-debug-toolbar==3.2.1 +django-debug-toolbar==4.2.0 # via -r requirements/dev.in django-extensions==3.1.2 # via -r requirements/dev.in @@ -102,11 +99,15 @@ django-ipware==3.0.2 # via # -r requirements/ci.txt # django-axes +django-jsonform==2.21.4 + # via + # -r requirements/ci.txt + # mozilla-django-oidc-db django-markup==1.3 # via # -r requirements/ci.txt # vng-api-common -django-ordered-model==3.4.1 +django-ordered-model==3.7.4 # via # -r requirements/ci.txt # django-admin-index @@ -118,9 +119,13 @@ django-phonenumber-field==5.2.0 # via # -r requirements/ci.txt # maykin-django-two-factor-auth +django-privates==2.0.0.post0 + # via + # -r requirements/ci.txt + # django-simple-certmanager django-redis==5.2.0 # via -r requirements/ci.txt -django-relativedelta==1.1.2 +django-relativedelta==2.0.0 # via # -r requirements/ci.txt # zgw-consumers @@ -130,7 +135,15 @@ django-rest-framework-condition==0.1.1 # vng-api-common django-rosetta==0.9.8 # via -r requirements/ci.txt -django-solo==1.1.5 +django-sendfile2==0.7.0 + # via + # -r requirements/ci.txt + # django-privates +django-simple-certmanager==1.4.1 + # via + # -r requirements/ci.txt + # zgw-consumers +django-solo==2.2.0 # via # -r requirements/ci.txt # mozilla-django-oidc-db @@ -141,19 +154,25 @@ django-webtest==1.9.7 django==3.2.23 # via # -r requirements/ci.txt + # django-admin-index # django-axes # django-choices # django-debug-toolbar # django-extensions # django-filter # django-formtools + # django-jsonform # django-markup # django-otp # django-phonenumber-field + # django-privates # django-redis # django-relativedelta # django-rest-framework-condition # django-rosetta + # django-sendfile2 + # django-simple-certmanager + # django-solo # djangorestframework # drf-nested-routers # drf-spectacular @@ -167,7 +186,7 @@ djangorestframework-camel-case==1.2.0 # via # -r requirements/ci.txt # vng-api-common -djangorestframework-gis==0.17 +djangorestframework-gis==1.0 # via -r requirements/ci.txt djangorestframework==3.12.4 # via @@ -210,7 +229,7 @@ flake8==7.0.0 # via -r requirements/dev.in freezegun==1.1.0 # via -r requirements/ci.txt -gemma-zds-client==1.0.0 +gemma-zds-client==1.0.1 # via # -r requirements/ci.txt # vng-api-common @@ -275,9 +294,9 @@ maykin-django-two-factor-auth[phonenumbers]==2.0.3 # via -r requirements/ci.txt mccabe==0.7.0 # via flake8 -mozilla-django-oidc-db==0.9.0 +mozilla-django-oidc-db==0.14.1 # via -r requirements/ci.txt -mozilla-django-oidc==1.2.4 +mozilla-django-oidc==4.0.0 # via # -r requirements/ci.txt # mozilla-django-oidc-db @@ -312,9 +331,7 @@ polib==1.1.1 # -r requirements/ci.txt # django-rosetta psycopg2==2.8.6 - # via - # -r requirements/ci.txt - # mozilla-django-oidc-db + # via -r requirements/ci.txt pycodestyle==2.11.1 # via flake8 pycparser==2.20 @@ -332,10 +349,12 @@ pyjwt==2.4.0 # -r requirements/ci.txt # gemma-zds-client # vng-api-common -pyopenssl==20.0.1 +pyopenssl==23.3.0 # via # -r requirements/ci.txt + # django-simple-certmanager # josepy + # zgw-consumers pyquery==1.4.3 # via -r requirements/ci.txt pyrsistent==0.17.3 @@ -406,8 +425,6 @@ six==1.15.0 # django-markup # isodate # jsonschema - # mozilla-django-oidc - # pyopenssl # python-dateutil # qrcode # requests-mock @@ -491,7 +508,7 @@ webtest==2.0.35 # via # -r requirements/ci.txt # django-webtest -zgw-consumers==0.15.2 +zgw-consumers==0.27.0 # via -r requirements/ci.txt zipp==3.17.0 # via importlib-metadata diff --git a/src/objects/accounts/__init__.py b/src/objects/accounts/__init__.py index 98f1a17b..e69de29b 100644 --- a/src/objects/accounts/__init__.py +++ b/src/objects/accounts/__init__.py @@ -1 +0,0 @@ -default_app_config = "objects.accounts.apps.AccountsConfig" diff --git a/src/objects/api/validators.py b/src/objects/api/validators.py index a1f44ab7..2b465bc1 100644 --- a/src/objects/api/validators.py +++ b/src/objects/api/validators.py @@ -13,21 +13,16 @@ class JsonSchemaValidator: code = "invalid-json-schema" + requires_context = True - def set_context(self, serializer): - """ - This hook is called by the serializer instance, - prior to the validation call being made. - """ - self.instance = getattr(serializer, "instance", None) - - def __call__(self, attrs): + def __call__(self, attrs, serializer): + instance = getattr(serializer, "instance", None) object_type = ( attrs.get("object", {}).get("object_type") - or self.instance.object.object_type + or instance.object.object_type ) - version = attrs.get("version") or self.instance.version - data = attrs.get("data", {}) or self.instance.data + version = attrs.get("version") or instance.version + data = attrs.get("data", {}) or instance.data if not object_type or not version or not data: return @@ -45,22 +40,15 @@ class IsImmutableValidator: message = _("This field can't be changed") code = "immutable-field" + requires_context = True - def set_context(self, serializer_field): - """ - This hook is called by the serializer instance, - prior to the validation call being made. - """ - # Determine the existing instance, if this is an update operation. - self.serializer_field = serializer_field - self.instance = getattr(serializer_field.parent, "instance", None) - - def __call__(self, new_value): + def __call__(self, new_value, serializer_field): + instance = getattr(serializer_field.parent, "instance", None) # no instance -> it's not an update - if not self.instance: + if not instance: return - current_value = get_attribute(self.instance, self.serializer_field.source_attrs) + current_value = get_attribute(instance, serializer_field.source_attrs) if new_value != current_value: raise serializers.ValidationError(self.message, code=self.code) @@ -94,18 +82,13 @@ def validate_data_attrs(value: str): class GeometryValidator: code = "geometry-not-allowed" message = _("This object type doesn't support geometry") + requires_context = True - def set_context(self, serializer): - """ - This hook is called by the serializer instance, - prior to the validation call being made. - """ - self.instance = getattr(serializer, "instance", None) - - def __call__(self, attrs): + def __call__(self, attrs, serializer): + instance = getattr(serializer, "instance", None) object_type = ( attrs.get("object", {}).get("object_type") - or self.instance.object.object_type + or instance.object.object_type ) geometry = attrs.get("geometry") diff --git a/src/objects/conf/base.py b/src/objects/conf/base.py index 9763b64a..5a22c360 100644 --- a/src/objects/conf/base.py +++ b/src/objects/conf/base.py @@ -69,7 +69,6 @@ # 'django.contrib.sitemaps', # External applications. "axes", - "django_better_admin_arrayfield", "drf_spectacular", "mozilla_django_oidc", "mozilla_django_oidc_db", @@ -79,6 +78,7 @@ "django_markup", "vng_api_common", "vng_api_common.notifications", + "simple_certmanager", "zgw_consumers", # 2fa apps "django_otp", diff --git a/src/objects/core/migrations/0028_alter_objectrecord_data.py b/src/objects/core/migrations/0028_alter_objectrecord_data.py new file mode 100644 index 00000000..b8026aaa --- /dev/null +++ b/src/objects/core/migrations/0028_alter_objectrecord_data.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.23 on 2024-01-18 10:35 + +import django.core.serializers.json +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0027_auto_20211203_1209"), + ] + + operations = [ + migrations.AlterField( + model_name="objectrecord", + name="data", + field=models.JSONField( + default=dict, + encoder=django.core.serializers.json.DjangoJSONEncoder, + help_text="Object data, based on OBJECTTYPE", + verbose_name="data", + ), + ), + ] diff --git a/src/objects/core/models.py b/src/objects/core/models.py index 10894698..8cf1255d 100644 --- a/src/objects/core/models.py +++ b/src/objects/core/models.py @@ -2,7 +2,6 @@ import uuid from django.contrib.gis.db.models import GeometryField -from django.contrib.postgres.fields import JSONField from django.core.exceptions import ValidationError from django.core.serializers.json import DjangoJSONEncoder from django.db import models @@ -91,7 +90,7 @@ class ObjectRecord(models.Model): _("version"), help_text=_("Version of the OBJECTTYPE for data in the object record"), ) - data = JSONField( + data = models.JSONField( _("data"), help_text=_("Object data, based on OBJECTTYPE"), default=dict, diff --git a/src/objects/token/migrations/0009_alter_permission_fields.py b/src/objects/token/migrations/0009_alter_permission_fields.py new file mode 100644 index 00000000..a9d8345f --- /dev/null +++ b/src/objects/token/migrations/0009_alter_permission_fields.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.23 on 2024-01-18 10:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("token", "0008_permission_fields"), + ] + + operations = [ + migrations.AlterField( + model_name="permission", + name="fields", + field=models.JSONField( + blank=True, + default=dict, + help_text="Fields allowed for this token in relation to objecttype versions. Supports only first level of the `record.data` properties", + null=True, + verbose_name="mode", + ), + ), + ] diff --git a/src/objects/token/models.py b/src/objects/token/models.py index 3da49986..e086fb45 100644 --- a/src/objects/token/models.py +++ b/src/objects/token/models.py @@ -1,7 +1,6 @@ import binascii import os -from django.contrib.postgres.fields import JSONField from django.core import exceptions from django.db import models from django.utils.translation import gettext_lazy as _ @@ -91,7 +90,7 @@ class Permission(models.Model): use_fields = models.BooleanField( _("use fields"), default=False, help_text=_("Use field-based authorization") ) - fields = JSONField( + fields = models.JSONField( _("mode"), blank=True, null=True, diff --git a/src/objects/utils/__init__.py b/src/objects/utils/__init__.py index 4425c532..e69de29b 100644 --- a/src/objects/utils/__init__.py +++ b/src/objects/utils/__init__.py @@ -1 +0,0 @@ -default_app_config = "objects.utils.apps.UtilsConfig"