Commit f93f2df0 authored by Jérome Perrin's avatar Jérome Perrin

catch validation faileds on workflow validations and put them in portal status message


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5493 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5b6ed740
...@@ -66,19 +66,25 @@ ...@@ -66,19 +66,25 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>o = context.getObject()\n <value> <string>from Products.DCWorkflow import ValidationFailed\n
\n
o = context.getObject()\n
\n \n
action_list = context.portal_workflow.getActionsFor(o)\n action_list = context.portal_workflow.getActionsFor(o)\n
action_list = filter(lambda x:x.has_key(\'id\'), action_list )\n action_list = filter(lambda x:x.has_key(\'id\'), action_list )\n
action_id_list = map(lambda x:x[\'id\'], action_list)\n action_id_list = map(lambda x:x[\'id\'], action_list)\n
\n \n
if workflow_action in action_id_list:\n if workflow_action in action_id_list:\n
\n try : \n
context.portal_workflow.doActionFor(\n context.portal_workflow.doActionFor( o,\n
o,\n
workflow_action,\n workflow_action,\n
comment = comment\n comment = comment\n
)\n )\n
except ValidationFailed, message: \n
if not batch :\n
context.REQUEST.RESPONSE.redirect(\n
"%s/view?portal_status_message=%s" %\n
(context.absolute_url(), message))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -128,13 +134,16 @@ if workflow_action in action_id_list:\n ...@@ -128,13 +134,16 @@ if workflow_action in action_id_list:\n
<string>workflow_action</string> <string>workflow_action</string>
<string>comment</string> <string>comment</string>
<string>batch</string> <string>batch</string>
<string>Products.DCWorkflow</string>
<string>ValidationFailed</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>o</string> <string>o</string>
<string>action_list</string> <string>action_list</string>
<string>filter</string> <string>filter</string>
<string>map</string> <string>map</string>
<string>action_id_list</string> <string>action_id_list</string>
<string>message</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -100,6 +100,9 @@ try:\n ...@@ -100,6 +100,9 @@ try:\n
context,\n context,\n
kw[\'workflow_action\'],\n kw[\'workflow_action\'],\n
**kw)\n **kw)\n
\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n
, \'portal_status_message=Status+changed.\' )\n
\n \n
except FormValidationError, validation_errors:\n except FormValidationError, validation_errors:\n
# Pack errors into the request\n # Pack errors into the request\n
...@@ -107,28 +110,12 @@ except FormValidationError, validation_errors:\n ...@@ -107,28 +110,12 @@ except FormValidationError, validation_errors:\n
request.set(\'field_errors\', field_errors)\n request.set(\'field_errors\', field_errors)\n
return form(request)\n return form(request)\n
\n \n
else:\n except ValidationFailed, error_message:\n
# We will check if there\'s an error_message\n
history_data = None\n
try : \n
history_data = context.portal_workflow.getInfoFor(ob=context.getObject(), name=\'history\')\n
except AttributeError : \n
pass\n
redirect_url = None\n
if history_data:\n
last_history_data = history_data[-1]\n
error_message = last_history_data.get(\'error_message\')\n
if error_message != None and error_message != \'\':\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n
, \'portal_status_message=%s\' % error_message\n , \'portal_status_message=%s\' % error_message\n
)\n )\n
pass\n
if redirect_url is None:\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n
, \'portal_status_message=Status+changed.\'\n
)\n
\n \n
context.REQUEST[ \'RESPONSE\' ].redirect( redirect_url )\n context.REQUEST[ \'RESPONSE\' ].redirect( redirect_url )\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -196,12 +183,9 @@ else:\n ...@@ -196,12 +183,9 @@ else:\n
<string>listbox_line</string> <string>listbox_line</string>
<string>tuple</string> <string>tuple</string>
<string>_apply_</string> <string>_apply_</string>
<string>redirect_url</string>
<string>validation_errors</string> <string>validation_errors</string>
<string>field_errors</string> <string>field_errors</string>
<string>history_data</string>
<string>AttributeError</string>
<string>redirect_url</string>
<string>last_history_data</string>
<string>error_message</string> <string>error_message</string>
</tuple> </tuple>
</value> </value>
......
2006-02-01 jerome
* catch validation faileds on workflow validations and put them in portal status message
2006-02-01 aurel 2006-02-01 aurel
* modify Base_callViewDialogMethod * modify Base_callViewDialogMethod
......
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