diff --git a/changes/TI-1333.feature b/changes/TI-1333.feature new file mode 100644 index 00000000000..e1ca0fef697 --- /dev/null +++ b/changes/TI-1333.feature @@ -0,0 +1 @@ +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 176400ab5bd..817666d4bcc 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 867481b5049..41f89e42a74 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,6 +138,7 @@ 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 1d313324d17..c2533902929 100644 --- a/opengever/api/tests/test_tasktemplate.py +++ b/opengever/api/tests/test_tasktemplate.py @@ -30,3 +30,31 @@ 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 new file mode 100644 index 00000000000..e69de29bb2d 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 new file mode 100644 index 00000000000..beb6d5ccc14 --- /dev/null +++ b/opengever/core/upgrades/20250127123059_update_task_template_text_field_to_rich_text/upgrade.py @@ -0,0 +1,23 @@ +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 a5e02810b70..83e226e2d2c 100644 --- a/opengever/tasktemplates/content/tasktemplate.py +++ b/opengever/tasktemplates/content/tasktemplate.py @@ -7,6 +7,7 @@ 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 @@ -86,11 +87,12 @@ class ITaskTemplate(model.Schema): # Bad naming: comments is more appropriated model.primary('text') - text = schema.Text( - title=_(u"label_text", default=u"Text"), + text = RichText( + title=_(u'label_text', default='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(