X-Git-Url: https://scm.cri.ensmp.fr/git/Portfolio.git/blobdiff_plain/2da869b2b46179d64c05eaac4081226fdbbbc9ff..e73353500c67453ef9663d67eaeee7dd46c358ee:/Products/Portfolio/skins/remove_to_selection.py diff --git a/Products/Portfolio/skins/remove_to_selection.py b/Products/Portfolio/skins/remove_to_selection.py new file mode 100755 index 0000000..2367ec1 --- /dev/null +++ b/Products/Portfolio/skins/remove_to_selection.py @@ -0,0 +1,38 @@ +##parameters=ajax='' +from Products.CMFCore.utils import getToolByName + +uidtool = getToolByName(context, 'portal_uidhandler') +utool = getToolByName(context, 'portal_url') +portal = utool.getPortalObject() +uid = uidtool.register(context) + +sd = context.session_data_manager.getSessionData(create = 1) + +selection = sd.get('objects_selection', []) +selDict = sd.get('objects_selection_dict', {}) + +lightboxpath = sd.get('lightboxpath', None) +selectionIsLightbox = False +if lightboxpath is None : + selection = sd.get('objects_selection', []) +else : + try : + lightbox = portal.restrictedTraverse(lightboxpath) + selection = lightbox.getUidList() + selectionIsLightbox = True + except KeyError : + sd.set('lightboxpath', None) + selection = sd.get('objects_selection', []) + + + +if selDict.has_key(uid) : + del selDict[uid] + selection.remove(uid) + if selectionIsLightbox : + lightbox.remove(uid) + sd['objects_selection'] = selection + sd['objects_selection_dict'] = selDict + +if not ajax: + return context.REQUEST.RESPONSE.redirect('%s/selection_view' % utool())