X-Git-Url: https://scm.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/b3b52f5b0ad754fd9036f816d0ab8e98a5373f40..fdb6f4e9ae1d1933e56c76b141fac14ac235960d:/skins/custom_control/folder_rename_control.py?ds=sidebyside diff --git a/skins/custom_control/folder_rename_control.py b/skins/custom_control/folder_rename_control.py index 4fc1163..1f0ae27 100755 --- a/skins/custom_control/folder_rename_control.py +++ b/skins/custom_control/folder_rename_control.py @@ -1,26 +1,45 @@ -##parameters=ids, new_ids, **kw +##parameters=items, **kw ##title=Rename objects in a folder ## from Products.CMFDefault.exceptions import CopyError from Products.Plinn.utils import translate _ = lambda msg : translate(msg, context) +ids, new_ids = zip(*[(i['id'], i['new_id']) for i in items]) +changed = 0 + +c = context.aq_explicit +for itemInfo in items : + item = getattr(c, itemInfo['id']) + if item.Title() != itemInfo['title'] : + item.setTitle(itemInfo['title']) + item.reindexObject() + changed = changed + 1 + if not ids == new_ids: - try: - skiped = context.manage_renameObjects(ids, new_ids) - if not skiped : - if len(ids) == 1: - return context.setStatus(True, _(u'Item renamed.')) - else: - return context.setStatus(True, _(u'Items renamed.')) - else : - if len(skiped) == 1 : - return context.setStatus(True, _( u'This item has not been renamed: "%s"') % ids[0] ) - else : - return context.setStatus(True - , _( u'These items have not been renamed: %s') % \ - ', '.join(['"%s"' % id for id in ids]) ) - except CopyError: - return context.setStatus(False, _(u'Rename failed.')) -else: - return context.setStatus(False, _(u'Nothing to change.')) + try: + skiped = context.manage_renameObjects(ids, new_ids) + if not skiped : + if len(ids) == 1: + return context.setStatus(True, _(u'Item renamed.')) + else: + return context.setStatus(True, _(u'Items renamed.')) + else : + if len(skiped) == 1 : + return context.setStatus(True, _( u'This item has not been renamed: "%s"') % ids[0] ) + else : + return context.setStatus(True + , _( u'These items have not been renamed: %s') % \ + ', '.join(['"%s"' % id for id in ids]) ) + except CopyError: + return context.setStatus(False, _(u'Rename failed.')) + + +elif not changed : + return context.setStatus(False, _(u'Nothing to change.')) +else : + if changed == 1: + return context.setStatus(True, _(u'Item renamed.')) + else: + return context.setStatus(True, _(u'Items renamed.')) + \ No newline at end of file