From f93f2df0005073d4bb29a416af6409142606cde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 1 Feb 2006 13:10:16 +0000 Subject: [PATCH] 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 --- .../erp5_core/Base_workflowStatusModify.xml | 19 ++++++++---- .../erp5_core/Workflow_statusModify.xml | 30 +++++-------------- .../ERP5/bootstrap/erp5_core/bt/change_log | 3 ++ 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_workflowStatusModify.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_workflowStatusModify.xml index 736f28a3b7..7af2b016a8 100755 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_workflowStatusModify.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_workflowStatusModify.xml @@ -66,19 +66,25 @@ </item> <item> <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 action_list = context.portal_workflow.getActionsFor(o)\n action_list = filter(lambda x:x.has_key(\'id\'), action_list )\n action_id_list = map(lambda x:x[\'id\'], action_list)\n \n if workflow_action in action_id_list:\n -\n - context.portal_workflow.doActionFor(\n - o,\n + try : \n + context.portal_workflow.doActionFor( o,\n workflow_action,\n comment = comment\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> </item> <item> @@ -128,13 +134,16 @@ if workflow_action in action_id_list:\n <string>workflow_action</string> <string>comment</string> <string>batch</string> + <string>Products.DCWorkflow</string> + <string>ValidationFailed</string> <string>_getattr_</string> -<string>context</string> + <string>context</string> <string>o</string> <string>action_list</string> <string>filter</string> <string>map</string> <string>action_id_list</string> + <string>message</string> </tuple> </value> </item> diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Workflow_statusModify.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Workflow_statusModify.xml index b6f62636b6..5e0536ef78 100755 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Workflow_statusModify.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Workflow_statusModify.xml @@ -100,6 +100,9 @@ try:\n context,\n kw[\'workflow_action\'],\n **kw)\n +\n + redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n + , \'portal_status_message=Status+changed.\' )\n \n except FormValidationError, validation_errors:\n # Pack errors into the request\n @@ -107,28 +110,12 @@ except FormValidationError, validation_errors:\n request.set(\'field_errors\', field_errors)\n return form(request)\n \n -else:\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 +except ValidationFailed, error_message:\n + redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n , \'portal_status_message=%s\' % error_message\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 - context.REQUEST[ \'RESPONSE\' ].redirect( redirect_url )\n +context.REQUEST[ \'RESPONSE\' ].redirect( redirect_url )\n </string> </value> </item> <item> @@ -196,12 +183,9 @@ else:\n <string>listbox_line</string> <string>tuple</string> <string>_apply_</string> + <string>redirect_url</string> <string>validation_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> </tuple> </value> diff --git a/product/ERP5/bootstrap/erp5_core/bt/change_log b/product/ERP5/bootstrap/erp5_core/bt/change_log index b75624a1bc..e3ae98449f 100755 --- a/product/ERP5/bootstrap/erp5_core/bt/change_log +++ b/product/ERP5/bootstrap/erp5_core/bt/change_log @@ -1,3 +1,6 @@ +2006-02-01 jerome +* catch validation faileds on workflow validations and put them in portal status message + 2006-02-01 aurel * modify Base_callViewDialogMethod -- 2.30.9