Commit 02e06ea3 authored by Tomáš Peterka's avatar Tomáš Peterka

[erp5_core] Reinforce comment FormBox re-validation

parent b511f0c6
...@@ -8,6 +8,7 @@ This script is intended as a dialog target. ...@@ -8,6 +8,7 @@ This script is intended as a dialog target.
:param comment: {str} optional comment :param comment: {str} optional comment
""" """
from Products.CMFCore.WorkflowCore import WorkflowException from Products.CMFCore.WorkflowCore import WorkflowException
from Products.Formulator.Errors import FormValidationError, ValidationError
def stripMyYour(key): def stripMyYour(key):
if key.startswith("your_") or key.startswith("my_"): if key.startswith("your_") or key.startswith("my_"):
...@@ -73,10 +74,17 @@ tag = 'folder_workflow_action_{:d}'.format(random.randint(0, 1000)) # Kato: how ...@@ -73,10 +74,17 @@ tag = 'folder_workflow_action_{:d}'.format(random.randint(0, 1000)) # Kato: how
priority = 3 priority = 3
batch_size = 100 batch_size = 100
workflow_action_kwargs = {}
if workflow_dialog is None: if workflow_dialog is None:
workflow_dialog_id = context.Base_getFormIdForWorkflowAction(form_id, '', workflow_action, uids=uids) workflow_dialog_id = context.Base_getFormIdForWorkflowAction(form_id, '', workflow_action, uids=uids)
workflow_dialog = getattr(context, workflow_dialog_id) workflow_dialog = getattr(context, workflow_dialog_id)
workflow_action_kwargs = workflow_dialog.validate_all(request, key_prefix='field_workflow_dialog') try:
workflow_action_kwargs = workflow_dialog.validate_all(request, key_prefix='field_workflow_dialog')
except FormValidationError, ValidationError:
workflow_action_kwargs["comment"] = (comment or
kwargs.get("field_workflow_dialog_your_comment", "") or
kwargs.get("field_workflow_dialog_my_comment", "") or
kwargs.get("field_workflow_dialog_comment", ""))
workflow_action_kwargs = {stripMyYour(key): value for key, value in workflow_action_kwargs.items()} workflow_action_kwargs = {stripMyYour(key): value for key, value in workflow_action_kwargs.items()}
workflow_action_kwargs['workflow_action'] = workflow_action workflow_action_kwargs['workflow_action'] = workflow_action
......
...@@ -75,10 +75,10 @@ ...@@ -75,10 +75,10 @@
<value> <value>
<list> <list>
<string>workflow_action</string> <string>workflow_action</string>
<string>workflow_dialog</string>
<string>workflow_dialog_my_workflow_action</string> <string>workflow_dialog_my_workflow_action</string>
<string>workflow_dialog_your_workflow_action</string> <string>workflow_dialog_your_workflow_action</string>
<string>workflow_action_rendered</string> <string>workflow_action_rendered</string>
<string>workflow_dialog</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>alternate_name</string> </key>
<value> <string></string> </value> <value> <string>my_workflow_action</string> </value>
</item> </item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>css_class</string> </key>
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string></string> </value> <value> <string>non-existing-dummy</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>workflow_dialog_my_action</string> </value> <value> <string>workflow_dialog_my_workflow_action</string> </value>
</item> </item>
<item> <item>
<key> <string>truncate</string> </key> <key> <string>truncate</string> </key>
......
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>alternate_name</string> </key>
<value> <string></string> </value> <value> <string>your_workflow_action</string> </value>
</item> </item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>css_class</string> </key>
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string></string> </value> <value> <string>non-existing-dummy</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>workflow_dialog_my_workflow_action</string> </value> <value> <string>workflow_dialog_your_workflow_action</string> </value>
</item> </item>
<item> <item>
<key> <string>truncate</string> </key> <key> <string>truncate</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment