Commit 097ccea2 authored by Eteri's avatar Eteri

erp5_project: delete project related data after deleting a project

parent c9db0528
from Products.DCWorkflow.DCWorkflow import ValidationFailed
error_list = []
data_supply_set = set(state_change['object'].getRelatedValueList(portal_type="Data Supply"))
data_analysis_set = set(state_change['object'].getRelatedValueList(portal_type="Data Analysis"))
if not data_supply_set:
return error_list
else:
project_validation_state = state_change['object'].getValidationState()
for data_supply in data_supply_set:
if data_supply.getValidationState() != "deleted" and data_supply.getValidationState() != "validated":
data_supply.delete()
else:
error_list.append(state_change['object'].Base_translateString("Error: Project contains active measurement position(s). It can not be invalidated, suspended or deleted."))
raise ValidationFailed, error_list
for data_analysis in data_analysis_set:
if data_analysis.getSimulationState() != "started":
if data_analysis.getSimulationState() != "deleted":
data_analysis.delete()
else:
error_list.append(state_change['object'].Base_translateString("Error: Project contains active measurement position(s). It can not be invalidated, suspended or deleted."))
raise ValidationFailed, error_list
for data_analysis_line in data_analysis.objectValues():
reference = data_analysis_line.getReference()
if reference == 'out_array' or reference == 'in_array' :
data_array = data_analysis_line.getAggregateValueList(portal_type = 'Data Array')[0]
if data_array.getValidationState() != "invalidated" and data_array.getValidationState() != "deleted":
data_array.invalidate()
if data_array.getValidationState() != "deleted":
data_array.delete()
return error_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Project_deleteProjectRelatedData</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Project_deleteProjectRelatedData</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -24,6 +24,7 @@
<tuple>
<string>action_type/workflow</string>
<string>destination/portal_workflow/project_workflow/state_deleted</string>
<string>before_script/portal_workflow/project_workflow/script_Project_deleteProjectRelatedData</string>
</tuple>
</value>
</item>
......
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