Skip to content

Commit

Permalink
Merge pull request #8117 from 4teamwork/amo/TI-1333/task_template_Wys…
Browse files Browse the repository at this point in the history
…iwygEditor

Change the task template text field to RichtextField
  • Loading branch information
Abdu-moustafa authored Jan 30, 2025
2 parents bb17b89 + f11adaa commit ee7da16
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions changes/TI-1333.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change task template `text field` from Text field to RichText field. [amo]
2 changes: 1 addition & 1 deletion docs/public/dev-manual/api/api_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ API Changelog

Breaking Changes
^^^^^^^^^^^^^^^^

- The task template text field was changed from a Text field to a RichTextField.

Other Changes
^^^^^^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion opengever/api/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_create_simple_process(self, browser):
"start_immediately": False,
"process": {
"title": "New employee",
"text": "A new employee arrives.",
"text": "<p> A new employee arrives.</p>",
"sequence_type": "sequential",
"items": [
{
Expand All @@ -138,6 +138,7 @@ def test_create_simple_process(self, browser):
self.assertEqual(1, len(children['added']))
main_task = children['added'].pop()

self.assertEqual("<p> A new employee arrives.</p>", 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)
Expand Down
28 changes: 28 additions & 0 deletions opengever/api/tests/test_tasktemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
Original file line number Diff line number Diff line change
@@ -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',
)
8 changes: 5 additions & 3 deletions opengever/tasktemplates/content/tasktemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ee7da16

Please sign in to comment.