From f29c29375a351150480183c3af7eef5e8352559b Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Mon, 28 Mar 2011 11:56:34 +0000
Subject: [PATCH] 2011-03-28 Kazuhiko * we should have at most only one
 published/released/shared document for each reference/language, i.e. we
 should not have both published and released document with the same
 reference/language at the same time.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44661 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/archivePublicVersion.xml          | 67 -------------------
 .../scripts/archiveReleasedVersion.xml        | 67 -------------------
 .../scripts/archiveSharedVersion.xml          | 67 -------------------
 .../scripts/archiveVersion.xml                | 23 ++++---
 .../transitions/publish.xml                   |  6 +-
 .../transitions/publish_alive.xml             |  6 +-
 .../transitions/release.xml                   |  6 +-
 .../transitions/release_alive.xml             |  6 +-
 .../transitions/share.xml                     |  6 +-
 .../transitions/share_alive.xml               |  6 +-
 bt5/erp5_dms/bt/change_log                    |  3 +
 bt5/erp5_dms/bt/revision                      |  2 +-
 12 files changed, 47 insertions(+), 218 deletions(-)
 delete mode 100644 bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archivePublicVersion.xml
 delete mode 100644 bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveReleasedVersion.xml
 delete mode 100644 bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveSharedVersion.xml

diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archivePublicVersion.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archivePublicVersion.xml
deleted file mode 100644
index e0677e73a8..0000000000
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archivePublicVersion.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>Script_magic</string> </key>
-            <value> <int>3</int> </value>
-        </item>
-        <item>
-            <key> <string>_bind_names</string> </key>
-            <value>
-              <object>
-                <klass>
-                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
-                </klass>
-                <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>_body</string> </key>
-            <value> <string>context.archiveVersion(state_change, validation_state=[\'published\', \'published_alive\'])\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string>state_change</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>archivePublicVersion</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveReleasedVersion.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveReleasedVersion.xml
deleted file mode 100644
index 93f3bba07e..0000000000
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveReleasedVersion.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>Script_magic</string> </key>
-            <value> <int>3</int> </value>
-        </item>
-        <item>
-            <key> <string>_bind_names</string> </key>
-            <value>
-              <object>
-                <klass>
-                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
-                </klass>
-                <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>_body</string> </key>
-            <value> <string>context.archiveVersion(state_change, validation_state=[\'released\', \'released_alive\'])\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string>state_change</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>archiveReleasedVersion</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveSharedVersion.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveSharedVersion.xml
deleted file mode 100644
index 314d01f33f..0000000000
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveSharedVersion.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>Script_magic</string> </key>
-            <value> <int>3</int> </value>
-        </item>
-        <item>
-            <key> <string>_bind_names</string> </key>
-            <value>
-              <object>
-                <klass>
-                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
-                </klass>
-                <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>_body</string> </key>
-            <value> <string>context.archiveVersion(state_change, validation_state=[\'shared\', \'shared_alive\'])\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string>state_change</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>archiveSharedVersion</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveVersion.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveVersion.xml
index ca1a27329b..2ace70cbaa 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveVersion.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/scripts/archiveVersion.xml
@@ -57,32 +57,35 @@ The previous version is archived automatically.\n
 This will only apply to documents with enough coordinates\n
 (ex. reference, language, version).\n
 """\n
-o = state_change[\'object\']\n
-reference = o.getReference()\n
+document = state_change[\'object\']\n
+reference = document.getReference()\n
 if not reference:\n
   # If this object has no reference, we can not do anything\n
   return\n
 \n
-language = o.getLanguage()\n
+portal = document.getPortalObject()\n
+portal_catalog = portal.portal_catalog\n
+language = document.getLanguage()\n
 if not language:\n
   # If language is None, we have to check is this document\n
   # is language independent. In this case, archival is possible\n
   # But if a document exists with same reference and defined\n
   # language, we can not do anything\n
-  for o in context.portal_catalog(reference=reference, validation_state=validation_state):\n
-    document = o.getObject()\n
-    if not document.getLanguage():\n
-      document.archive()\n
+  for old_document in portal_catalog(reference=reference, validation_state=validation_state):\n
+    old_document = old_document.getObject()\n
+    if not old_document.getLanguage():\n
+      old_document.archive()\n
   return\n
 \n
 # We can now archive all documents with same reference and language in published state\n
-for o in context.portal_catalog(reference=reference, language=language, validation_state=validation_state):\n
-  o.getObject().archive()\n
+for old_document in portal_catalog(reference=reference, language=language, validation_state=validation_state):\n
+  old_document = old_document.getObject()\n
+  old_document.archive()\n
 </string> </value>
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>state_change, validation_state=[\'published\', \'published_alive\']</string> </value>
+            <value> <string>state_change, validation_state=[\'published\', \'published_alive\', \'released\', \'released_alive\', \'shared\', \'shared_alive\']</string> </value>
         </item>
         <item>
             <key> <string>id</string> </key>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish.xml
index 855b4b287a..4dbb81708b 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish.xml
@@ -10,6 +10,10 @@
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
         </item>
+        <item>
+            <key> <string>actbox_icon</string> </key>
+            <value> <string></string> </value>
+        </item>
         <item>
             <key> <string>actbox_name</string> </key>
             <value> <string></string> </value>
@@ -20,7 +24,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>archivePublicVersion</string> </value>
+            <value> <string>archiveVersion</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish_alive.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish_alive.xml
index 331d932702..13e36df5b9 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish_alive.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/publish_alive.xml
@@ -10,6 +10,10 @@
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
         </item>
+        <item>
+            <key> <string>actbox_icon</string> </key>
+            <value> <string></string> </value>
+        </item>
         <item>
             <key> <string>actbox_name</string> </key>
             <value> <string></string> </value>
@@ -20,7 +24,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>archivePublicVersion</string> </value>
+            <value> <string>archiveVersion</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release.xml
index f894de081e..c32be40ba0 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release.xml
@@ -10,6 +10,10 @@
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
         </item>
+        <item>
+            <key> <string>actbox_icon</string> </key>
+            <value> <string></string> </value>
+        </item>
         <item>
             <key> <string>actbox_name</string> </key>
             <value> <string></string> </value>
@@ -20,7 +24,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>archiveReleasedVersion</string> </value>
+            <value> <string>archiveVersion</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release_alive.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release_alive.xml
index 18a268dfa7..3103a89ea2 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release_alive.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/release_alive.xml
@@ -10,6 +10,10 @@
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
         </item>
+        <item>
+            <key> <string>actbox_icon</string> </key>
+            <value> <string></string> </value>
+        </item>
         <item>
             <key> <string>actbox_name</string> </key>
             <value> <string></string> </value>
@@ -20,7 +24,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>archiveReleasedVersion</string> </value>
+            <value> <string>archiveVersion</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share.xml
index b62aecfea2..b170ea9617 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share.xml
@@ -10,6 +10,10 @@
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
         </item>
+        <item>
+            <key> <string>actbox_icon</string> </key>
+            <value> <string></string> </value>
+        </item>
         <item>
             <key> <string>actbox_name</string> </key>
             <value> <string></string> </value>
@@ -20,7 +24,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>archiveSharedVersion</string> </value>
+            <value> <string>archiveVersion</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share_alive.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share_alive.xml
index b7b8412ba4..4324419864 100644
--- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share_alive.xml
+++ b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_publication_workflow/transitions/share_alive.xml
@@ -10,6 +10,10 @@
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
         </item>
+        <item>
+            <key> <string>actbox_icon</string> </key>
+            <value> <string></string> </value>
+        </item>
         <item>
             <key> <string>actbox_name</string> </key>
             <value> <string></string> </value>
@@ -20,7 +24,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>archiveSharedVersion</string> </value>
+            <value> <string>archiveVersion</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_dms/bt/change_log b/bt5/erp5_dms/bt/change_log
index e55c484846..70e3c5af44 100644
--- a/bt5/erp5_dms/bt/change_log
+++ b/bt5/erp5_dms/bt/change_log
@@ -1,3 +1,6 @@
+2011-03-28 Kazuhiko
+* we should have at most only one published/released/shared document for each reference/language, i.e. we should not have both published and released document with the same reference/language at the same time.
+
 2010-07-08 mohamadou
 * revert the last commit, setting permission on this state breaks some sites security.
 
diff --git a/bt5/erp5_dms/bt/revision b/bt5/erp5_dms/bt/revision
index 09c2854e84..1280674f38 100644
--- a/bt5/erp5_dms/bt/revision
+++ b/bt5/erp5_dms/bt/revision
@@ -1 +1 @@
-1246
\ No newline at end of file
+1247
\ No newline at end of file
-- 
2.30.9