[Erp5-report] r33670 kazuhiko - in /erp5/trunk/products/ERP5: Document/ bootstrap/erp5_core...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Mar 11 17:59:31 CET 2010


Author: kazuhiko
Date: Thu Mar 11 17:59:31 2010
New Revision: 33670

URL: http://svn.erp5.org?rev=33670&view=rev
Log:
if removed workflow is still used somewhere else, make the default choice 'unchecked' and displays 'Removed but used'.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiedObject.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_viewInstallationDialog/listbox_choice.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_getModifiedObjectList.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_viewMultiInstallationDialog/listbox_choice.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
    erp5/trunk/products/ERP5/tests/testBusinessTemplate.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Thu Mar 11 17:59:31 2010
@@ -1602,7 +1602,7 @@
   # 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 @@
         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 @@
         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:

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiedObject.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiedObject.xml?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiedObject.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiedObject.xml [utf8] Thu Mar 11 17:59:31 2010
@@ -107,11 +107,13 @@
       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

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_viewInstallationDialog/listbox_choice.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_viewInstallationDialog/listbox_choice.xml?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_viewInstallationDialog/listbox_choice.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_viewInstallationDialog/listbox_choice.xml [utf8] Thu Mar 11 17:59:31 2010
@@ -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>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_getModifiedObjectList.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_getModifiedObjectList.xml?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_getModifiedObjectList.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_getModifiedObjectList.xml [utf8] Thu Mar 11 17:59:31 2010
@@ -112,7 +112,7 @@
         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

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_viewMultiInstallationDialog/listbox_choice.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_viewMultiInstallationDialog/listbox_choice.xml?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_viewMultiInstallationDialog/listbox_choice.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_viewMultiInstallationDialog/listbox_choice.xml [utf8] Thu Mar 11 17:59:31 2010
@@ -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>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] Thu Mar 11 17:59:31 2010
@@ -1,1 +1,1 @@
-1508
+1509

Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] Thu Mar 11 17:59:31 2010
@@ -2414,6 +2414,27 @@
     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):
     """
@@ -2991,6 +3012,76 @@
                        CheckBuiltBuildingState \
                        CheckNotInstalledInstallationState \
                        InstallWithoutForceBusinessTemplate \
+                       Tic \
+                       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 \




More information about the Erp5-report mailing list