Commit 7ac21fb5 authored by Jérome Perrin's avatar Jérome Perrin

core: fix Folder_cut to check relations of sub-objects

We now have getRelationCountForDeletion API for this.
parent 31e71335
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
def Object_hasRelation(obj):
# Check if there is some related objets.
result = 0
for o in obj.getIndexableChildValueList():
for related in obj.portal_categories.getRelatedValueList(obj):
if related.getRelativeUrl().startswith(obj.getRelativeUrl()):
continue
elif related.getRelativeUrl().startswith('portal_simulation') :
continue
else:
result = 1
break
return result
context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids) context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name) uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after # make sure nothing is checked after
...@@ -28,7 +14,7 @@ if uids != []: ...@@ -28,7 +14,7 @@ if uids != []:
object_used = 0 object_used = 0
object_list = [x.getObject() for x in context.portal_catalog(uid=uids)] object_list = [x.getObject() for x in context.portal_catalog(uid=uids)]
object_used = sum([Object_hasRelation(x) for x in object_list]) object_used = sum([x.getRelationCountForDeletion() for x in object_list])
if object_used > 0: if object_used > 0:
if object_used == 1: if object_used == 1:
......
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