X-Git-Url: https://scm.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/3c4367d8e03450e9a73e61f4247145d2b6c86a33..959d888c17d1403d2eeecc19bc4b5e2c8d1debf6:/Products/Plinn/skins/custom_control/folder_delete_control.py diff --git a/Products/Plinn/skins/custom_control/folder_delete_control.py b/Products/Plinn/skins/custom_control/folder_delete_control.py new file mode 100644 index 0000000..28feabd --- /dev/null +++ b/Products/Plinn/skins/custom_control/folder_delete_control.py @@ -0,0 +1,47 @@ +##parameters=ids, **kw +##title=Delete objects from a folder +## +request = context.REQUEST +response = request.RESPONSE + +if request.cookies.has_key('__cp'): + contextPath = context.getPhysicalPath() + depth = len(contextPath) + 1 + strContextPath = ''.join(contextPath) + + cp = context.getCPInfo() + + deletedObPaths = {} + for id in ids : + deletedObPaths[strContextPath + id] = True + + indexes, paths = [], cp[1] + + for i in range(len(paths)) : + path = paths[i] + try : + firstPart = path[:depth] + if deletedObPaths.has_key(''.join(firstPart)) : + indexes.append(i) + except IndexError : continue + + context.popCP(indexes) + + +ret = context.manage_delObjects( list(ids) ) +msg='' +if ret : + ignored = [] + for id in ret : + o = getattr(context, id, None) + if o : + ignored.append(o.title_or_id()) + #TODO : translate messages + #from Products.PlacelessTranslationService.MessageID import MessageIDFactory + #_ = MessageIDFactory('plinn') + _ = lambda x : lambda : x + translate = lambda msg : _(msg)().decode('iso-8859-1').encode('utf-8') + msg = translate('You are not allowed to delete: ') + ', '.join(ignored) + +msg = msg or 'Item%s deleted.' % ( len(ids) != 1 and 's' or '' ) +return context.setStatus( True, msg)