diff --git a/docs/installation/upgrade-300.rst b/docs/installation/upgrade-300.rst index 3dddadc039..82c096d543 100644 --- a/docs/installation/upgrade-300.rst +++ b/docs/installation/upgrade-300.rst @@ -91,6 +91,13 @@ active locale field (``name_nl`` or ``name_en``) during imports. Instead, the ``translations`` key existed. We recommend re-creating the exports on a newer version of Open Forms. +Removal of ``formStep`` reference in form logic +----------------------------------------------- + +The ``formStep`` key was deprecated in favour of ``formStepUuid`` and the conversion +code has been removed. This may affect form exports from before Open Forms 2.1.0. We +recommend re-creating the exports on a newer version of Open Forms. + Removal of /api/v2/location/get-street-name-and-city endpoint ============================================================= diff --git a/pyright.pyproject.toml b/pyright.pyproject.toml index 55892ac49c..4c1a6ed7fd 100644 --- a/pyright.pyproject.toml +++ b/pyright.pyproject.toml @@ -24,6 +24,8 @@ include = [ # Formio tooling "src/openforms/formio/typing/", "src/openforms/formio/formatters/", + # Core forms app + "src/openforms/forms/api/serializers/logic/action_serializers.py", # Payments "src/openforms/payments/models.py", # Interaction with the outside world diff --git a/src/openforms/forms/api/serializers/logic/action_serializers.py b/src/openforms/forms/api/serializers/logic/action_serializers.py index ddf4f1993f..abba78d6fe 100644 --- a/src/openforms/forms/api/serializers/logic/action_serializers.py +++ b/src/openforms/forms/api/serializers/logic/action_serializers.py @@ -1,12 +1,9 @@ -import warnings from datetime import date -from django.urls import resolve from django.utils.translation import gettext_lazy as _ from drf_polymorphic.serializers import PolymorphicSerializer from drf_spectacular.utils import extend_schema_serializer -from furl import furl from json_logic.typing import Primitive from rest_framework import serializers @@ -168,18 +165,6 @@ class LogicComponentActionSerializer(serializers.Serializer): ) ), ) - # Deprecated field! form_step_uuid should be used instead - form_step = serializers.URLField( - allow_null=True, - required=False, # validated against the action.type - allow_blank=True, - label=_("form step"), - help_text=_( - "The form step that will be affected by the action. This field is " - "required if the action type is `%(action_type)s`, otherwise optional." - ) - % {"action_type": LogicActionTypes.step_not_applicable}, - ) form_step_uuid = ActionFormStepUUIDField( allow_null=True, required=False, # validated against the action.type @@ -192,27 +177,17 @@ class LogicComponentActionSerializer(serializers.Serializer): ) action = LogicActionPolymorphicSerializer() - def validate(self, data: dict) -> dict: + def validate(self, attrs: dict) -> dict: """ 1. Check that the component is supplied depending on the action type. 2. Check that the value for date variables has the right format """ - action_type = data.get("action", {}).get("type") - action_value = data.get("action", {}).get("value") - component = data.get("component") - form_step = data.get("form_step") - - if form_step and not data.get("form_step_uuid"): - warnings.warn( - "Logic action 'formStep' is deprecated, use 'formStepUuid' instead", - DeprecationWarning, - ) - # normalize to UUID following deprecation of URL reference - match = resolve(furl(form_step).path) - data["form_step_uuid"] = match.kwargs["uuid"] + action_type = attrs.get("action", {}).get("type") + action_value = attrs.get("action", {}).get("value") + component = attrs.get("component") - form_step_uuid = data.get("form_step_uuid") - variable = data.get("variable") + form_step_uuid = attrs.get("form_step_uuid") + variable = attrs.get("variable") if ( action_type @@ -254,7 +229,10 @@ def validate(self, data: dict) -> dict: if form_var.data_type == FormVariableDataTypes.date: try: - date.fromisoformat(action_value) + # type check muted since we handle it at runtime + date.fromisoformat( + action_value + ) # pyright: ignore[reportArgumentType] except (ValueError, TypeError) as ex: raise serializers.ValidationError( { @@ -270,7 +248,7 @@ def validate(self, data: dict) -> dict: if ( action_type and action_type == LogicActionTypes.step_not_applicable - and (not form_step and not form_step_uuid) + and not form_step_uuid ): raise serializers.ValidationError( { @@ -281,4 +259,4 @@ def validate(self, data: dict) -> dict: code="blank", ) - return data + return attrs diff --git a/src/openforms/forms/tests/test_import_export.py b/src/openforms/forms/tests/test_import_export.py index dd5b178026..d0cad6ee0b 100644 --- a/src/openforms/forms/tests/test_import_export.py +++ b/src/openforms/forms/tests/test_import_export.py @@ -873,8 +873,7 @@ def test_import_form_with_disable_step_logic(self): "actions": [ { "action": {"type": "step-not-applicable"}, - # In versions <= 2.0, we used the url of the form step, but this was replaced with the UUID - "form_step": "http://127.0.0.1:8999/api/v2/forms/324cadce-a627-4e3f-b117-37ca232f16b2/steps/a54864c6-c460-48bd-a520-eced60ffb209", + "form_step_uuid": "a54864c6-c460-48bd-a520-eced60ffb209", } ], "form": "http://testserver/api/v2/forms/324cadce-a627-4e3f-b117-37ca232f16b2",