[Erp5-report] r10004 - in /erp5/trunk/products/ERP5/bootstrap/erp5_core: SkinTemplateItem/p...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Sep 15 17:13:21 CEST 2006
Author: romain
Date: Fri Sep 15 17:13:19 2006
New Revision: 10004
URL: http://svn.erp5.org?rev=10004&view=rev
Log:
Modify Folder_delete.
The trash button does not allow anymore to remove object from the database when there is a workflow associated to this object (excepted for edit_workflow).
In such case, there must be a workflow transition called "delete_action", which changes the state of the object to "deleted".
Modified:
erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_delete.xml
erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_delete.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_delete.xml?rev=10004&r1=10003&r2=10004&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_delete.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_delete.xml Fri Sep 15 17:13:19 2006
@@ -106,42 +106,101 @@
elif uids is not None:\n
# Check if there is some related objets.\n
object_used = 0\n
- for uid in uids:\n
- object = context.portal_catalog(uid=uid)[0].getObject()\n
- if Object_hasRelation(object):\n
- object_used += 1\n
- if object_used>0:\n
- if object_used == 1:\n
- message = N_("Sorry,+1+Item+Is+In+Use.")\n
- qs = \'?portal_status_message=%s\' % message\n
+\n
+ object_list = [x.getObject() for x in context.portal_catalog(uid=uids)]\n
+ object_used = sum([Object_hasRelation(x) for x in object_list])\n
+\n
+ if object_used > 0:\n
+ if object_used == 1:\n
+ message = N_("Sorry,+1+Item+Is+In+Use.")\n
+ else:\n
+ message = N_("Sorry,+${count}+Items+Are+In+Use.",\n
+ mapping={\'count\': repr(object_used)})\n
+ qs = \'?portal_status_message=%s\' % message \n
+ else:\n
+\n
+ # Do not delete objects which have a workflow history \n
+ object_to_remove_list = []\n
+ object_to_delete_list = []\n
+\n
+ for object in object_list:\n
+\n
+ workflow_id_list = [x.id for x in object.portal_workflow.getWorkflowsFor(object)]\n
+ # XXX Remove edit_workflow, which should no prevent deletion\n
+ try:\n
+ workflow_id_list.remove("edit_workflow")\n
+ except ValueError:\n
+ pass\n
+\n
+ # If a workflow manage a history, \n
+ # object should not be removed, but only put in state deleted\n
+ for wf_id in workflow_id_list:\n
+ # It is important to use the history variable\n
+ try:\n
+ list_history_item = context.portal_workflow.getInfoFor(\n
+ ob=object, name="history", wf_id=wf_id)\n
+ # XXX Can not use WorkflowException\n
+ except ConflictError:\n
+ raise\n
+ except:\n
+ pass\n
+ else:\n
+ object_to_delete_list.append(object)\n
+ break\n
else:\n
- message = N_("Sorry,+${count}+Items+Are+In+Use.",\n
- mapping={\'count\': repr(object_used)})\n
- qs = \'?portal_status_message=%s\' % message \n
- else:\n
- try : \n
- object_ids = \', \'.join([x.getObject().getId()\n
- for x in context.portal_catalog(uid=uids)])\n
- context.manage_delObjects(uids=uids, REQUEST=REQUEST)\n
+ object_to_remove_list.append(object)\n
+\n
+ # Remove some objects\n
+ try: \n
+ if object_to_remove_list != []:\n
+ context.manage_delObjects(\n
+ uids=[x.getUid() for x in object_to_remove_list],\n
+ REQUEST=REQUEST)\n
+ except ConflictError: \n
+ raise\n
+ except Exception, message : \n
+ qs = \'?portal_status_message=%s\' % message\n
+ else:\n
+ object_ids = [x.getId() for x in object_to_remove_list]\n
comment = N_(\'Deleted objects: ${object_ids}\',\n
mapping={\'object_ids\': object_ids})\n
if \'edit_action\' in [x.get(\'id\', \'\') for x in\n
- context.portal_workflow.getActionsFor(context)] :\n
+ context.portal_workflow.getActionsFor(context)]:\n
# record object deletion in workflow history\n
context.getPortalObject().portal_workflow.doActionFor(\n
context,\n
\'edit_action\',\n
comment=comment)\n
+\n
message = N_("Deleted.")\n
+\n
+ # Change workflow state of others objects\n
+ not_deleted_count = 0\n
+ for object in object_to_delete_list:\n
+ try:\n
+ context.getPortalObject().portal_workflow.doActionFor(\n
+ object,\n
+ \'delete_action\')\n
+ except ConflictError:\n
+ raise\n
+ except:\n
+ not_deleted_count += 1\n
+ pass\n
+\n
+ # Generate message\n
+ if not_deleted_count == 1:\n
+ message = N_("Sorry+You+Can+Not+Delete+${count}+Item.",\n
+ mapping={\'count\': not_deleted_count})\n
+ elif not_deleted_count > 1:\n
+ message = N_("Sorry+You+Can+Not+Delete+${count}+Items.",\n
+ mapping={\'count\': not_deleted_count})\n
qs = \'?portal_status_message=%s\' % message\n
- except ConflictError : raise\n
- except Exception, message : \n
- qs = \'?portal_status_message=%s\' % message\n
+\n
else:\n
message = N_("Please+select+one+or+more+items+first.")\n
qs = \'?portal_status_message=%s\' % message\n
\n
-return REQUEST.RESPONSE.redirect( ret_url + qs )\n
+return REQUEST.RESPONSE.redirect("%s%s" % (ret_url, qs))\n
]]></string> </value>
@@ -153,7 +212,19 @@
</value>
</item>
<item>
+ <key> <string>_dav_writelocks</string> </key>
+ <value>
+ <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+ </value>
+ </item>
+ <item>
<key> <string>_filepath</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_owner</string> </key>
<value>
<none/>
</value>
@@ -210,17 +281,24 @@
<string>message</string>
<string>None</string>
<string>object_used</string>
- <string>_getiter_</string>
- <string>uid</string>
- <string>_getitem_</string>
- <string>object</string>
- <string>repr</string>
<string>append</string>
<string>$append0</string>
+ <string>_getiter_</string>
<string>x</string>
+ <string>object_list</string>
+ <string>sum</string>
+ <string>repr</string>
+ <string>object_to_remove_list</string>
+ <string>object_to_delete_list</string>
+ <string>object</string>
+ <string>workflow_id_list</string>
+ <string>ValueError</string>
+ <string>wf_id</string>
+ <string>list_history_item</string>
+ <string>Exception</string>
<string>object_ids</string>
<string>comment</string>
- <string>Exception</string>
+ <string>not_deleted_count</string>
</tuple>
</value>
</item>
@@ -262,4 +340,25 @@
</dictionary>
</pickle>
</record>
+ <record id="2" aka="AAAAAAAAAAI=">
+ <pickle>
+ <tuple>
+ <tuple>
+ <string>Persistence</string>
+ <string>PersistentMapping</string>
+ </tuple>
+ <none/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>_container</string> </key>
+ <value>
+ <dictionary/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
</ZopeData>
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=10004&r1=10003&r2=10004&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision Fri Sep 15 17:13:19 2006
@@ -1,1 +1,1 @@
-67
+68
More information about the Erp5-report
mailing list