From 20c45a97cca07e9a195e229bfccc04131dbd5265 Mon Sep 17 00:00:00 2001 From: Abdelrahman Moustafa Date: Fri, 31 Jan 2025 15:25:31 +0100 Subject: [PATCH] Revert "Change the task template text field to RichtextField / to fix the GEVER E2E tests" This reverts commit f11adaa74e50d1c5372e7acc614d6a56154bcde7. --- changes/TI-1333.feature | 1 - docs/public/dev-manual/api/api_changelog.rst | 2 +- opengever/api/tests/test_process.py | 3 +- opengever/api/tests/test_tasktemplate.py | 28 ------------------- .../__init__.py | 0 .../upgrade.py | 23 --------------- .../tasktemplates/content/tasktemplate.py | 8 ++---- 7 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 changes/TI-1333.feature delete mode 100644 opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/__init__.py delete mode 100644 opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/upgrade.py diff --git a/changes/TI-1333.feature b/changes/TI-1333.feature deleted file mode 100644 index e1ca0fef697..00000000000 --- a/changes/TI-1333.feature +++ /dev/null @@ -1 +0,0 @@ -Change task template `text field` from Text field to RichText field. [amo] diff --git a/docs/public/dev-manual/api/api_changelog.rst b/docs/public/dev-manual/api/api_changelog.rst index 817666d4bcc..176400ab5bd 100644 --- a/docs/public/dev-manual/api/api_changelog.rst +++ b/docs/public/dev-manual/api/api_changelog.rst @@ -8,7 +8,7 @@ API Changelog Breaking Changes ^^^^^^^^^^^^^^^^ -- The task template text field was changed from a Text field to a RichTextField. + Other Changes ^^^^^^^^^^^^^ diff --git a/opengever/api/tests/test_process.py b/opengever/api/tests/test_process.py index 41f89e42a74..867481b5049 100644 --- a/opengever/api/tests/test_process.py +++ b/opengever/api/tests/test_process.py @@ -114,7 +114,7 @@ def test_create_simple_process(self, browser): "start_immediately": False, "process": { "title": "New employee", - "text": "

A new employee arrives.

", + "text": "A new employee arrives.", "sequence_type": "sequential", "items": [ { @@ -138,7 +138,6 @@ def test_create_simple_process(self, browser): self.assertEqual(1, len(children['added'])) main_task = children['added'].pop() - self.assertEqual("

A new employee arrives.

", main_task.text.output) self.assertEqual(browser.json['@id'], main_task.absolute_url()) self.assertEqual(u'New employee', main_task.title) self.assertEqual(self.regular_user.getId(), main_task.issuer) diff --git a/opengever/api/tests/test_tasktemplate.py b/opengever/api/tests/test_tasktemplate.py index c2533902929..1d313324d17 100644 --- a/opengever/api/tests/test_tasktemplate.py +++ b/opengever/api/tests/test_tasktemplate.py @@ -30,31 +30,3 @@ def test_tasktemplate_responsible_has_a_responsible_client(self, browser): browser.json.get('responsible')) self.assertEquals({u'title': u'Finanz\xe4mt', u'token': u'fa'}, browser.json.get('responsible_client')) - - @browsing - def test_tasktemplate_with_richt_text_description(self, browser): - self.login(self.administrator, browser=browser) - - data = { - '@type': u'opengever.tasktemplates.tasktemplate', - 'title': 'Testtasktemplate', - 'task_type': {'token': 'information'}, - 'deadline': 7, - 'issuer': {'token': INTERACTIVE_ACTOR_RESPONSIBLE_ID}, - "responsible": { - 'token': "fa:{}".format(self.secretariat_user.id), - 'title': u'Finanzamt: K\xe4thi B\xe4rfuss' - }, - "text": "task template description" - } - - browser.open(self.tasktemplatefolder, method="POST", - headers=self.api_headers, data=json.dumps(data)) - - self.assertEquals( - { - u'data': u'task template description', - u'content-type': u'text/html', - u'encoding': u'utf8' - }, browser.json.get("text") - ) diff --git a/opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/__init__.py b/opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/upgrade.py b/opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/upgrade.py deleted file mode 100644 index beb6d5ccc14..00000000000 --- a/opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/upgrade.py +++ /dev/null @@ -1,23 +0,0 @@ -from ftw.upgrade import UpgradeStep -from plone.app.textfield import IRichTextValue -from plone.app.textfield.value import RichTextValue - - -class UpdateTaskTemplateTextFieldToRichText(UpgradeStep): - """Update task template text field to rich text. - """ - - def __call__(self): - query = {'object_provides': "opengever.tasktemplates.content.tasktemplate.ITaskTemplate"} - msg = "Change task template text field from text field to rich text field" - - for task in self.objects(query, msg): - if IRichTextValue.providedBy(task.text): - continue - - task.text = RichTextValue( - raw=task.text or "", - mimeType='text/html', - outputMimeType='text/x-html-safe', - encoding='utf-8', - ) diff --git a/opengever/tasktemplates/content/tasktemplate.py b/opengever/tasktemplates/content/tasktemplate.py index 83e226e2d2c..a5e02810b70 100644 --- a/opengever/tasktemplates/content/tasktemplate.py +++ b/opengever/tasktemplates/content/tasktemplate.py @@ -7,7 +7,6 @@ from opengever.tasktemplates import _ from opengever.tasktemplates.sources import TaskResponsibleSourceBinder from opengever.tasktemplates.sources import TaskTemplateIssuerSourceBinder -from plone.app.textfield import RichText from plone.autoform import directives as form from plone.dexterity.browser.add import DefaultAddForm from plone.dexterity.browser.add import DefaultAddView @@ -87,12 +86,11 @@ class ITaskTemplate(model.Schema): # Bad naming: comments is more appropriated model.primary('text') - text = RichText( - title=_(u'label_text', default='Text'), + text = schema.Text( + title=_(u"label_text", default=u"Text"), description=_(u"help_text", default=u""), required=False, - default_mime_type='text/html', - output_mime_type='text/x-html-safe') + ) form.widget(preselected=checkbox.SingleCheckBoxFieldWidget) preselected = schema.Bool(