Commit 9eb9586d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

if removed workflow is still used somewhere else, make the default choice...

if removed workflow is still used somewhere else, make the default choice 'unchecked' and displays 'Removed but used'.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33670 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 51bb8b90
......@@ -1602,7 +1602,7 @@ class WorkflowTemplateItem(ObjectTemplateItem):
# So we hide modified subobjects to the user and we always reinstall
# (or remove) everything.
def preinstall(self, context, installed_item, **kw):
def preinstall(self, context, installed_item, installed_bt, **kw):
modified_object_dict = ObjectTemplateItem.preinstall(self, context,
installed_item, **kw)
modified_workflow_dict = {}
......@@ -1612,6 +1612,28 @@ class WorkflowTemplateItem(ObjectTemplateItem):
modified_workflow_dict.setdefault('/'.join(path[:2]), ('Modified', state[1]))
else:
modified_workflow_dict[modified_object] = state
removed_workflow_id_list = [x[0].split('/', 1)[1] \
for x in modified_workflow_dict.iteritems() \
if x[1][0] == 'Removed']
if len(removed_workflow_id_list) > 0:
installed_chain_list = [[y.strip() for y in x.split('|')] for x in \
installed_bt.getTemplatePortalTypeWorkflowChainList()]
new_chain_list = [[y.strip() for y in x.split('|')] for x in \
context.getTemplatePortalTypeWorkflowChainList()]
chain_dict = getChainByType(context)[1]
for workflow_id in removed_workflow_id_list:
affected_portal_type_set = set([x[0][6:] for x in \
chain_dict.iteritems() \
if workflow_id in \
[y.strip() for y in x[1].split(',')]])
safe_portal_type_set = set([x[0] for x in installed_chain_list \
if x[1] == workflow_id]) - \
set([x[0] for x in new_chain_list \
if x[1] == workflow_id])
if affected_portal_type_set - safe_portal_type_set:
value = modified_workflow_dict['portal_workflow/%s' % workflow_id]
modified_workflow_dict['portal_workflow/%s' % workflow_id] = \
('Removed but used', value[1])
return modified_workflow_dict
def install(self, context, trashbin, **kw):
......@@ -5079,7 +5101,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
if new_item is not None:
if installed_item is not None and hasattr(installed_item, '_objects'):
modified_object = new_item.preinstall(context=self,
installed_item=installed_item)
installed_item=installed_item,
installed_bt=installed_bt)
if len(modified_object) > 0:
modified_object_list.update(modified_object)
else:
......
......@@ -107,11 +107,13 @@ for object_id in keys:\n
choice_item_list=[[upgrade_title, \'install\']]\n
else:\n
choice_item_list=[[backup_title, \'backup\']]\n
elif object_state == \'Removed\':\n
elif object_state in (\'Removed\', \'Removed but used\'):\n
if object_class in no_backup_dict:\n
choice_item_list=[[remove_title, \'remove\']]\n
else:\n
choice_item_list=[[save_and_remove_title, \'save_and_remove\']]\n
else:\n
choice_item_list = [[install_title, \'install\']]\n
\n
line.edit(object_id=object_id,\n
object_state=object_state,\n
......
......@@ -259,7 +259,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.choice_item_list and cell.choice_item_list[0][1] or []</string> </value>
<value> <string>python:(cell.choice_item_list and cell.object_state != \'Removed but used\') and cell.choice_item_list[0][1] or []</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -112,7 +112,7 @@ for bt in bt_id_list:\n
choice_item_list = [[upgrade_title, \'install\']]\n
else:\n
choice_item_list = [[backup_title, \'backup\']]\n
elif object_state == \'Removed\':\n
elif object_state in (\'Removed\', \'Removed but used\'):\n
if object_class in no_backup_dict:\n
choice_item_list = [[remove_title, \'remove\']]\n
else:\n
......
......@@ -259,7 +259,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.choice_item_list[0][1]</string> </value>
<value> <string>python:(cell.choice_item_list and cell.object_state != \'Removed but used\') and cell.choice_item_list[0][1] or []</string> </value>
</item>
</dictionary>
</pickle>
......
1508
\ No newline at end of file
1509
\ No newline at end of file
......@@ -2414,6 +2414,27 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
import_bt.install(force=0, object_to_update=install_object_dict,
update_catalog=1)
def stepInstallWithRemoveCheckedBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
"""
Install importzed business template
"""
import_bt = sequence.get('import_bt')
object_list = import_bt.preinstall()
install_object_dict = {}
for obj in object_list.keys():
state = object_list[obj][0]
if state in ('Removed', 'Removed but used'):
install_state = 'save_and_remove'
elif state == 'Modified':
install_state = 'backup'
elif state == 'New':
install_state = 'install'
else:
install_state = ""
install_object_dict[obj] = install_state
import_bt.install(force=0, object_to_update=install_object_dict,
update_catalog=1)
def stepInstallDuplicatedBusinessTemplate(self, sequence=None,
sequence_list=None, **kw):
"""
......@@ -2995,6 +3016,76 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
CheckInstalledInstallationState \
CheckBuiltBuildingState \
CheckSkinsLayers \
CheckWorkflowExists \
CheckWorkflowChainRemoved \
SaveWorkflowChain \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_042_BusinessTemplateWithWorkflowRemoved(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Business Template With Remove Of Workflow'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
CreatePortalType \
CreateWorkflow \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddWorkflowToBusinessTemplate \
AddWorkflowChainToBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveWorkflow \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallBusinessTemplate \
ModifyWorkflowChain \
Tic \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
CheckNoTrashBin \
CheckSkinsLayers \
CheckWorkflowExists \
CheckWorkflowChainExists \
CreateSecondBusinessTemplate \
UseSecondBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
Tic \
Pdb \
InstallWithRemoveCheckedBusinessTemplate \
Tic \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
CheckSkinsLayers \
CheckWorkflowRemoved \
CheckWorkflowChainRemoved \
SaveWorkflowChain \
......
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