Skip to content

Commit

Permalink
Merge pull request #4975 from open-formulieren/cleanup/remove-cosign-…
Browse files Browse the repository at this point in the history
…patching

💥 Remove the cosign information tag patching
  • Loading branch information
sergei-maertens authored Dec 30, 2024
2 parents eeae60c + 75372c0 commit 56eb862
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 192 deletions.
8 changes: 8 additions & 0 deletions docs/installation/upgrade-300.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ The ``formStep`` key was deprecated in favour of ``formStepUuid`` and the conver
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 cosign template tag patching
---------------------------------------

In Open Forms 2.3, the template tag ``{% cosign_information %}`` was introduced and
automatically added to confirmation templates during import if it was absent. This
automatic patching has now been removed. We recommend re-creating the exports on Open
Forms 2.3 or newer.

Removal of /api/v2/location/get-street-name-and-city endpoint
=============================================================

Expand Down
29 changes: 0 additions & 29 deletions src/openforms/emails/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import re

from rest_framework import serializers

from openforms.translations.api.serializers import ModelTranslationsSerializer
from openforms.utils.migrations_utils.regex import add_cosign_info_templatetag

from ..models import ConfirmationEmailTemplate

Expand All @@ -20,29 +17,3 @@ class Meta:
"cosign_content",
"translations",
)

def to_internal_value(self, data):
if content := data.get("content"):
data["content"] = self._add_cosign_templatetag(content)

for language_code, translations in data.get("translations", {}).items():
if not (translated_content := translations.get("content")):
continue

data["translations"][language_code]["content"] = (
self._add_cosign_templatetag(translated_content)
)

return super().to_internal_value(data)

def _add_cosign_templatetag(self, content):
is_import = self.context.get("is_import", False)

if not is_import:
return content

match = re.search(r"\{%\s?cosign_information\s?%\}", content)
if not match:
content = add_cosign_info_templatetag(content)

return content
154 changes: 0 additions & 154 deletions src/openforms/forms/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,160 +922,6 @@ def test_export_with_filetype_information(self, m_get_solo):

self.assertIsInstance(export_data, dict)

@tag("gh-3182")
def test_import_form_without_cosign_tag(self):
resources = {
"forms": [
{
"active": True,
"authentication_backends": [],
"is_deleted": False,
"login_required": False,
"maintenance_mode": False,
"name": "Test Form",
"internal_name": "Test Form",
"product": None,
"show_progress_indicator": True,
"slug": "test-form",
"url": "http://testserver/api/v2/forms/324cadce-a627-4e3f-b117-37ca232f16b2",
"uuid": "324cadce-a627-4e3f-b117-37ca232f16b2",
"confirmation_email_template": {
"content": "Some content {% appointment_information %}\n{% payment_information %}",
"subject": "A subject",
"translations": {
"en": {
"content": "Some content {% appointment_information %}\n{% payment_information %}",
"subject": "A subject",
},
"nl": {
"content": "Wat inhoud {% appointment_information %}\n{% payment_information %}",
"subject": "Een onderwerp",
},
},
},
}
],
"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",
},
]
},
"name": "Def 1",
"slug": "test-definition-1",
"url": "http://testserver/api/v2/form-definitions/f0dad93b-333b-49af-868b-a6bcb94fa1b8",
"uuid": "f0dad93b-333b-49af-868b-a6bcb94fa1b8",
},
],
"formLogic": [],
}

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)
form = Form.objects.get(slug="test-form")

self.assertEqual(
form.confirmation_email_template.content_en,
"Some content {% cosign_information %}\n{% appointment_information %}\n{% payment_information %}",
)
self.assertEqual(
form.confirmation_email_template.content_nl,
"Wat inhoud {% cosign_information %}\n{% appointment_information %}\n{% payment_information %}",
)

@tag("gh-3182")
def test_import_form_without_cosign_tag_in_one_language(self):
resources = {
"forms": [
{
"active": True,
"authentication_backends": [],
"is_deleted": False,
"login_required": False,
"maintenance_mode": False,
"name": "Test Form",
"internal_name": "Test Form",
"product": None,
"show_progress_indicator": True,
"slug": "test-form",
"url": "http://testserver/api/v2/forms/324cadce-a627-4e3f-b117-37ca232f16b2",
"uuid": "324cadce-a627-4e3f-b117-37ca232f16b2",
"confirmation_email_template": {
"content": "Some content {% appointment_information %}\n{% payment_information %}",
"subject": "A subject",
"translations": {
"en": {
"content": "Some content {% appointment_information %}\n{% payment_information %}",
"subject": "A subject",
},
"nl": {
"content": "",
"subject": "",
},
},
},
}
],
"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",
},
]
},
"name": "Def 1",
"slug": "test-definition-1",
"url": "http://testserver/api/v2/form-definitions/f0dad93b-333b-49af-868b-a6bcb94fa1b8",
"uuid": "f0dad93b-333b-49af-868b-a6bcb94fa1b8",
},
],
"formLogic": [],
}

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)
form = Form.objects.get(slug="test-form")

self.assertEqual(
form.confirmation_email_template.content_en,
"Some content {% cosign_information %}\n{% appointment_information %}\n{% payment_information %}",
)
self.assertEqual(
form.confirmation_email_template.content_nl,
"",
)

def test_import_applies_converters(self):
def add_foo(component):
component["foo"] = "bar"
Expand Down
9 changes: 0 additions & 9 deletions src/openforms/utils/migrations_utils/regex.py

This file was deleted.

0 comments on commit 56eb862

Please sign in to comment.