Skip to content

Commit

Permalink
💥 [#3283] Drop legacy formio translation converter
Browse files Browse the repository at this point in the history
Per the deprecation warning we drop support for exports containing
the legacy translation store.
  • Loading branch information
sergei-maertens committed Nov 18, 2024
1 parent 5042ea1 commit 288b6a0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 528 deletions.
19 changes: 1 addition & 18 deletions src/openforms/forms/api/serializers/form_definition.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

from django.urls import reverse
from django.utils.translation import gettext_lazy as _

Expand All @@ -14,7 +12,6 @@
ModelTranslationsSerializer,
)

from ...fd_translations_converter import process_component_tree
from ...models import Form, FormDefinition
from ...validators import (
validate_form_definition_is_reusable,
Expand Down Expand Up @@ -145,24 +142,10 @@ def to_representation(self, instance):
def validate(self, attrs):
attrs = super().validate(attrs)
if self.instance:
assert isinstance(self.instance, FormDefinition)
validate_form_definition_is_reusable(
self.instance, new_value=attrs.get("is_reusable")
)

# during import, process legacy format component translations
if self.context.get("is_import", False) and (
translations_store := attrs.get("component_translations")
):
warnings.warn(
"Form-definition component translations are deprecated, the "
"compatibility layer wil be removed in Open Forms 3.0.",
DeprecationWarning,
)
process_component_tree(
components=attrs["configuration"]["components"],
translations_store=translations_store,
)

return attrs


Expand Down
177 changes: 0 additions & 177 deletions src/openforms/forms/fd_translations_converter.py

This file was deleted.

70 changes: 0 additions & 70 deletions src/openforms/forms/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,76 +1067,6 @@ def test_rountrip_form_with_theme_override(self):
imported_form = Form.objects.exclude(pk=form.pk).get()
self.assertIsNone(imported_form.theme)

def test_import_form_with_legacy_formio_component_translations_format(self):
"""
Legacy translations need to be converted to the new format.
"""
resources = {
"forms": [
{
"active": True,
"authentication_backends": [],
"is_deleted": False,
"login_required": False,
"maintenance_mode": False,
"name": "Test Form 1",
"internal_name": "Test Form Internal 1",
"product": None,
"show_progress_indicator": True,
"slug": "translations",
"url": "http://testserver/api/v2/forms/324cadce-a627-4e3f-b117-37ca232f16b2",
"uuid": "324cadce-a627-4e3f-b117-37ca232f16b2",
}
],
"formSteps": [
{
"form": "http://testserver/api/v2/forms/324cadce-a627-4e3f-b117-37ca232f16b2",
"form_definition": "http://testserver/api/v2/form-definitions/f0dad93b-333b-49af-868b-a6bcb94fa1b8",
"index": 0,
"slug": "test-step-1",
"uuid": "3ca01601-cd20-4746-bce5-baab47636823",
},
],
"formDefinitions": [
{
"configuration": {
"components": [
{
"key": "textfield",
"type": "textfield",
"label": "TEXTFIELD_LABEL",
},
]
},
"name": "Def 1 - With condition",
"slug": "test-definition-1",
"url": "http://testserver/api/v2/form-definitions/f0dad93b-333b-49af-868b-a6bcb94fa1b8",
"uuid": "f0dad93b-333b-49af-868b-a6bcb94fa1b8",
"component_translations": {
"nl": {
"TEXTFIELD_LABEL": "Tekstveld",
}
},
},
],
}

with zipfile.ZipFile(self.filepath, "w") as zip_file:
for name, data in resources.items():
zip_file.writestr(f"{name}.json", json.dumps(data))

call_command("import", import_file=self.filepath)

fd = FormDefinition.objects.get()
textfield = fd.configuration["components"][0]

self.assertIn("openForms", textfield)
self.assertIn("translations", textfield["openForms"])
self.assertIn("nl", textfield["openForms"]["translations"])
nl_translations = textfield["openForms"]["translations"]["nl"]
self.assertIn("label", nl_translations)
self.assertEqual(nl_translations["label"], "Tekstveld")

@tag("gh-3975")
def test_import_form_with_old_service_fetch_config(self):
resources = {
Expand Down
Loading

0 comments on commit 288b6a0

Please sign in to comment.