Commit 8bfa04b1 authored by wenjie.zheng's avatar wenjie.zheng

erp5_core: Folder_generateWorkflowReport local modification.

parent 70973c72
...@@ -50,81 +50,88 @@ ...@@ -50,81 +50,88 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>listbox = []\n
result_dict = {}\n
portal = context.getPortalObject()\n translate_state_dict = {}\n
translateString = portal.Base_translateString\n state_dict={}\n
getWorkflowsFor = portal.portal_workflow.getWorkflowsFor\n portal_type_dict={}\n
state_variable_set = set()\n workflow_dict={}\n
add = state_variable_set.add\n portal_workflow = context.portal_workflow\n
type_state_variable_workflow_dict = {}\n content_type_list = context.allowedContentTypes()\n
type_workflow_state_count_dict_dict = {}\n content_type_list.sort()\n
workflow_translated_title_dict = {}\n \n
workflow_translated_state_title_dict = {}\n translateString = context.Base_translateString\n
portal_type_translated_title_dict = {}\n \n
for portal_type in context.allowedContentTypes():\n workflow_tool = context.portal_workflow\n
for portal_type in content_type_list:\n
portal_type_id = portal_type.getId()\n portal_type_id = portal_type.getId()\n
portal_type_translated_title_dict[portal_type_id] = translateString(portal_type.getTitle())\n workflow_list = workflow_tool.getWorkflowsFor(portal_type_id)\n
for workflow in getWorkflowsFor(portal_type_id):\n # Retrieve the workflows by portal_type\n
state_container = getattr(workflow, \'states\', None)\n for workflow in workflow_list:\n
if state_container is not None and len(state_container) > 1:\n workflow_title = workflow.title\n
state_var = workflow.state_var\n workflow_state_dict = workflow.getStateValueList()\n
workflow_id = workflow.getId()\n # not \'edit_workflow\' because state variable is not in catalog\n
workflow_translated_title_dict[workflow_id] = translateString(workflow.title)\n if workflow_state_dict != {} and\\\n
type_state_variable_workflow_dict[(portal_type_id, state_var)] = workflow_id\n workflow.getId() != \'edit_workflow\':\n
state_count_dict = type_workflow_state_count_dict_dict.setdefault((portal_type_id, workflow_id), {})\n #retrieve state_var to search in the catalog the states use by the\n
translated_state_title_dict = workflow_translated_state_title_dict.setdefault(workflow_id, {})\n #workflow\n
for state in state_container.objectValues():\n state_var = workflow.getStateVariable()\n
state_id = state.getId()\n if state_var is None:\n
# TODO: support workflow-specific translations\n state_var = \'state\'\n
translated_state_title_dict[state_id] = translateString(state.title)\n result_list = context.Base_zCountByWorkflowState(portal_type=portal_type_id,\n
state_count_dict[state_id] = 0\n state_name=state_var)\n
add(state_var)\n if not ((len(result_list) == 1) and (result_list[0][0] is None)):\n
column_list = [\'portal_type\'] + list(state_variable_set)\n for result in result_list:\n
COUNT = \'count(*)\'\n portal_type_dict = result_dict.get(portal_type_id,{})\n
if use_selection:\n workflow_dict = portal_type_dict.get(workflow_title,{})\n
selection_kw = portal.portal_selections.getSelectionParamsFor(selection_name).copy()\n workflow_dict.update({result[0]:result[1]})\n
selection_kw.pop(\'limit\', None)\n portal_type_dict.update({workflow_title:workflow_dict})\n
query = portal.portal_catalog.getSQLCatalog().buildQuery(selection_kw)\n result_dict.update({portal_type_id:portal_type_dict})\n
else:\n # store the title states for the translation\n
query = None\n if not translate_state_dict.has_key(result[0]):\n
for line in context.searchFolder(group_by=column_list, select_list=[COUNT] + column_list, query=query):\n state_title = workflow_state_dict.get(result[0]).title_or_id()\n
portal_type = line.portal_type\n translate_state_dict[result[0]] = state_title\n
count = getattr(line, COUNT)\n \n
for state_variable in state_variable_set:\n #Display the result\n
workflow = type_state_variable_workflow_dict.get((line.portal_type, state_variable))\n state_list_dict = {}\n
state = getattr(line, state_variable)\n portal_type_list = result_dict.keys()\n
if workflow is None:\n portal_type_list.sort()\n
assert not state, (portal_type, state_variable, state)\n for portal_type in portal_type_list:\n
continue\n workflow_list = result_dict[portal_type].keys()\n
state_count_dict = type_workflow_state_count_dict_dict[(portal_type, workflow)]\n for workflow_title in workflow_list:\n
state_count_dict[state] = count + state_count_dict[state]\n listbox.append({\'translated_portal_type\': \'%s - %s\' %\\\n
listbox = []\n (translateString(portal_type), translateString(workflow_title)),\n
append = listbox.append\n \'state\' : \'\',\n
for (portal_type, workflow), state_count_dict in sorted(type_workflow_state_count_dict_dict.iteritems(), key=lambda x: x[0]):\n \'count\' : \'\'})\n
if sum(state_count_dict.values()):\n state_list = result_dict[portal_type][workflow_title].keys()\n
append({\n state_list.sort()\n
\'translated_portal_type\': \'%s - %s\' % (portal_type_translated_title_dict[portal_type], workflow_translated_title_dict[workflow]),\n for state in state_list:\n
\'state\' : \'\',\n result_count = result_dict[portal_type][workflow_title][state]\n
\'count\' : \'\',\n count = state_list_dict.get(state, 0) + result_count\n
})\n # account the number of items by state\n
translated_state_title_dict = workflow_translated_state_title_dict[workflow]\n state_list_dict.update({state:count})\n
for state, count in sorted(state_count_dict.iteritems(), key=lambda x: x[0]):\n listbox.append({\'translated_portal_type\': \'\',\n
if count:\n \'state\' : translateString(translate_state_dict[state]),\n
append({\n \'count\' : result_count})\n
\'translated_portal_type\': \'\',\n \n
\'state\': translated_state_title_dict[state],\n #Display the total by state\n
\'count\': count,\n listbox.append({\'translated_portal_type\': translateString(\'All\'),\n
})\n \'state\' : \'\',\n
portal.Base_updateDialogForm(listbox=listbox, empty_line_number=0)\n \'count\' : \'\'})\n
state_list = state_list_dict.keys()\n
state_list.sort()\n
for state in state_list:\n
listbox.append({\'translated_portal_type\': \'\',\n
\'state\' : translateString(translate_state_dict[state]),\n
\'count\' : state_list_dict[state]})\n
\n
context.Base_updateDialogForm(listbox=listbox, empty_line_number=0)\n
return context.Folder_viewWorkflowReport()\n return context.Folder_viewWorkflowReport()\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>use_selection=False, selection_name=None</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</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