From: Benoît Pin Date: Thu, 28 Aug 2014 12:46:22 +0000 (+0200) Subject: Factorisation / bugfix. X-Git-Url: https://scm.cri.ensmp.fr/git/Portfolio.git/commitdiff_plain/5e9d5a6ac7b22dbb732acd070728ae8e079ac2ff Factorisation / bugfix. --- diff --git a/skins/getSelectionPhotosInfos.py b/skins/getSelectionPhotosInfos.py index 80c52f9..362f76d 100644 --- a/skins/getSelectionPhotosInfos.py +++ b/skins/getSelectionPhotosInfos.py @@ -1,8 +1,6 @@ ##parameters=pho_start=None, batch_size=None from Products.CMFCore.utils import getToolByName from Products.Plinn.PloneMisc import Batch -from Products.Portfolio.utils import translate -def _(message) : return translate(message, context).encode('utf-8') uidh = getToolByName(context, 'portal_uidhandler') utool = getToolByName(context, 'portal_url') @@ -28,8 +26,9 @@ else : selection = req.SESSION.get('objects_selection', []) -start = pho_start if pho_start is not None else 0 brains = [uidh.getBrain(uid) for uid in selection] +start = pho_start if pho_start is not None else 0 +batch_size = batch_size if batch_size is not None else context.default_batch_size batch = Batch(brains, batch_size, start, quantumleap=1) cart = req.SESSION.get('cart', None) diff --git a/skins/selection_view.py b/skins/selection_view.py index aec9043..0a419a7 100755 --- a/skins/selection_view.py +++ b/skins/selection_view.py @@ -1,69 +1,29 @@ ##parameters= from Products.CMFCore.utils import getToolByName -from Products.Plinn.PloneMisc import Batch from Products.Portfolio.utils import translate def _(message) : return translate(message, context).encode('utf-8') -uidh = getToolByName(context, 'portal_uidhandler') +req = context.REQUEST utool = getToolByName(context, 'portal_url') -pptool = getToolByName(context, 'portal_photo_print', None) portal = utool.getPortalObject() portal_url = utool() -portalDepth = len(portal.getPhysicalPath()) -req = context.REQUEST -toUrl = req.physicalPathToURL # check if a lightbox is currently selected lightboxpath = req.SESSION.get('lightboxpath', None) selectionIsLightbox = False -if lightboxpath is None : - selection = req.SESSION.get('objects_selection', []) -else : +if lightboxpath is not None : try : lightbox = portal.restrictedTraverse(lightboxpath) - selection = lightbox.getUidList() selectionIsLightbox = True except: req.SESSION.set('lightboxpath', None) - selection = req.SESSION.get('objects_selection', []) - -start = req.get('b_start', 0) -brains = [uidh.getBrain(uid) for uid in selection] -batch = Batch(brains, context.default_batch_size, start, orphan=1, quantumleap=1)#, b_start_str='pho_start') -cart = req.SESSION.get('cart', None) - -infos = [] -for index, b in enumerate(batch) : - path = b.getPath().split('/') - path.insert(portalDepth, 'selectioncontext') - p = b.getObject() - if pptool : - buyable = bool(pptool.getPrintingOptionsFor(p)) - if cart and cart.locked : - buyable = False - else : - buyable = False - - d = {'href': toUrl('/'.join(path)) - ,'thumbUrl' : '%s/getThumbnail' % b.getURL() - ,'thumbSize' : b.getThumbnailSize - ,'title' : ('%s - %s' % (b.Title, b.Description)).strip(' -') - ,'cmf_uid':b.cmf_uid - ,'className':'' - ,'buyable' : buyable - ,'o':b - } - infos.append(d) - -features = {} -features['del'] = lambda b : '%s/remove_to_selection' % b.getURL() -features['cart'] = lambda b : '%s/get_slide_buyable_items' % b.getURL() # breadcrumbs customization if selectionIsLightbox : lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) else : lastBcTitle = _('My selection') + breadcrumbs = [ { 'id' : 'root' , 'title' : portal.title @@ -76,10 +36,7 @@ breadcrumbs = [ options = {} -options['infos'] = infos -options['batch'] = batch -options['features'] = features - +options.update(context.getSelectionPhotosInfos()) options['container_type'] = 'selection' options['selectionIsLightbox'] = selectionIsLightbox options['breadcrumbs'] = breadcrumbs