Commit cf68e016 authored by Sebastien Robin's avatar Sebastien Robin

simulation: improve change "If divergence is solved by other user, then show a nice message."

Do not handle solving issues in Workflow_statusModify, use directly script attached to the
dialog of solving divergence. Also, previous code was no longer working properly with latest
simulation
parent 6cb4afdd
...@@ -64,8 +64,18 @@ if not listbox:\n ...@@ -64,8 +64,18 @@ if not listbox:\n
item[\'listbox_key\'] = key\n item[\'listbox_key\'] = key\n
repaired_listbox.append(item)\n repaired_listbox.append(item)\n
listbox = repaired_listbox\n listbox = repaired_listbox\n
\n \n
line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n
\n
def displayParallelChangeMessage():\n
message = translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message}, **kw)\n
\n
# if we are not divergence any more\n
if len(line_list) == 0:\n
return displayParallelChangeMessage()\n
\n
line = None\n
for listbox_dict in listbox:\n for listbox_dict in listbox:\n
listbox_key = listbox_dict[\'listbox_key\']\n listbox_key = listbox_dict[\'listbox_key\']\n
line = [x for x in line_list if x.getPath() == listbox_key][0]\n line = [x for x in line_list if x.getPath() == listbox_key][0]\n
...@@ -80,6 +90,10 @@ for listbox_dict in listbox:\n ...@@ -80,6 +90,10 @@ for listbox_dict in listbox:\n
else:\n else:\n
line.setProperty(property, value)\n line.setProperty(property, value)\n
\n \n
# if divergence solving is already ongoing and will be fixed by activities\n
if line is None:\n
return displayParallelChangeMessage()\n
\n
solver_process = line.getParentValue()\n solver_process = line.getParentValue()\n
solver_process.buildTargetSolverList()\n solver_process.buildTargetSolverList()\n
solver_process.solve()\n solver_process.solve()\n
......
...@@ -51,8 +51,15 @@ ...@@ -51,8 +51,15 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>request= context.REQUEST\n <value> <string>request= context.REQUEST\n
from Products.ERP5Type.Message import translateString\n
\n
listbox = request.get(\'listbox\')\n listbox = request.get(\'listbox\')\n
line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n
\n
if len(line_list) == 0:\n
message = translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message}, **kw)\n
\n
for listbox_key in listbox:\n for listbox_key in listbox:\n
listbox_dict = listbox[listbox_key]\n listbox_dict = listbox[listbox_key]\n
line = [x for x in line_list if x.getPath() == listbox_key][0]\n line = [x for x in line_list if x.getPath() == listbox_key][0]\n
...@@ -72,7 +79,7 @@ return context.Delivery_viewSolveDivergenceDialog(listbox=listbox)\n ...@@ -72,7 +79,7 @@ return context.Delivery_viewSolveDivergenceDialog(listbox=listbox)\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>listbox=[],**kw</string> </value> <value> <string>form_id=\'view\', listbox=[],**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -74,13 +74,8 @@ try:\n ...@@ -74,13 +74,8 @@ try:\n
except FormValidationError, validation_errors:\n except FormValidationError, validation_errors:\n
# Pack errors into the request\n # Pack errors into the request\n
field_errors = form.ErrorFields(validation_errors)\n field_errors = form.ErrorFields(validation_errors)\n
# Only for solve divergence dialog.\n request.set(\'field_errors\', field_errors)\n
if dialog_id == \'Delivery_viewSolveDivergenceDialog\' and set([error.error_key for error in field_errors.values()])==set([\'unknown_selection\']):\n return form(request)\n
message = translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message}, **kw)\n
else:\n
request.set(\'field_errors\', field_errors)\n
return form(request)\n
\n \n
# XXX: this is a duplication from form validation code in Base_callDialogMethod\n # XXX: this is a duplication from form validation code in Base_callDialogMethod\n
# Correct fix is to factorise this script with Base_callDialogMethod, not to\n # Correct fix is to factorise this script with Base_callDialogMethod, not to\n
......
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