Commit 4e8750fd authored by Jérome Perrin's avatar Jérome Perrin

Translating in a workflow script is a mistake. One should raise a...

Translating in a workflow script is a mistake. One should raise a ValidationFailed with a Message instance so that translations is performed when the message is displayed, not when it's stored in the database.
Also use newer checkConsistency ConsistencyMessage API

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14277 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1bf63acf
...@@ -68,22 +68,19 @@ ...@@ -68,22 +68,19 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
object = state_change[\'object\']\n object = state_change[\'object\']\n
N_ = object.Base_translateString\n
\n \n
check_result = object.checkConsistency()\n check_result = object.checkConsistency()\n
\n \n
if len(check_result) > 0:\n if check_result:\n
check_type = N_(check_result[0][-1])\n err = check_result[0]\n
# TODO: use nice url encoding method there instead of replace()\n if hasattr(err, \'getTranslatedMessage\'):\n
check_details = check_result[0][-2].replace(\'<\', \'&lt;\').replace(\'>\', \'&gt;\')\n raise ValidationFailed, err.getTranslatedMessage()\n
raise ValidationFailed, "%s : %s" % (check_type, check_details)\n # backward compatibility:\n
raise ValidationFailed, "%s: %s" % (err[4], err[3])\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -134,14 +131,14 @@ if len(check_result) > 0:\n ...@@ -134,14 +131,14 @@ if len(check_result) > 0:\n
<string>state_change</string> <string>state_change</string>
<string>Products.DCWorkflow.DCWorkflow</string> <string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string> <string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>object</string> <string>object</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>N_</string>
<string>check_result</string> <string>check_result</string>
<string>len</string> <string>err</string>
<string>check_type</string> <string>hasattr</string>
<string>check_details</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
316 317
\ No newline at end of file \ No newline at end of file
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