From 0971623cf1c52edd330de6dd62a455be497f4ac6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 2 Apr 2014 10:56:23 +0200 Subject: [PATCH] tabs -> spaces --- skins/selectioncontext.py | 146 +++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/skins/selectioncontext.py b/skins/selectioncontext.py index f042b6d..36727f6 100644 --- a/skins/selectioncontext.py +++ b/skins/selectioncontext.py @@ -18,116 +18,116 @@ toUrl = req.physicalPathToURL resp = req.RESPONSE if traverse_subpath[-1] == 'photo_view_ajax' : - photoSubPath = traverse_subpath[:-1] - ajax = True + photoSubPath = traverse_subpath[:-1] + ajax = True else : - photoSubPath = traverse_subpath - ajax = False - + photoSubPath = traverse_subpath + ajax = False + photo = portal.restrictedTraverse(photoSubPath) photouid = uidh.register(photo) lightboxpath = req.SESSION.get('lightboxpath', None) selectionIsLightbox = False if lightboxpath is None : - selection = req.SESSION.get('objects_selection', []) + selection = req.SESSION.get('objects_selection', []) else : - try : - lightbox = portal.restrictedTraverse(lightboxpath) - selection = lightbox.getUidList() - selectionIsLightbox = True - except: - req.SESSION.set('lightboxpath', None) - selection = req.SESSION.get('objects_selection', []) + try : + lightbox = portal.restrictedTraverse(lightboxpath) + selection = lightbox.getUidList() + selectionIsLightbox = True + except: + req.SESSION.set('lightboxpath', None) + selection = req.SESSION.get('objects_selection', []) if pptool : - buyable = bool(pptool.getPrintingOptionsFor(photo)) - sd = context.session_data_manager.getSessionData(create=1) - cart = sd.get('cart', None) - if cart and cart.locked : - buyable = False + buyable = bool(pptool.getPrintingOptionsFor(photo)) + sd = context.session_data_manager.getSessionData(create=1) + cart = sd.get('cart', None) + if cart and cart.locked : + buyable = False else : - buyable = False + buyable = False options['buyable'] = buyable infos = [] posOfPhoto = 0 if ajax == True : - try : posOfPhoto = selection.index(photouid) - except ValueError : pass - options['backToContextUrl'] = '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize) - photoPath = list(photo.getPhysicalPath()) - photoPath.insert(portalDepth, 'selectioncontext') - options['lastBcUrl'] = toUrl(photoPath) - meth = getattr(photo, 'photo_view_ajax_template') - return meth(req, resp, **options) + try : posOfPhoto = selection.index(photouid) + except ValueError : pass + options['backToContextUrl'] = '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize) + photoPath = list(photo.getPhysicalPath()) + photoPath.insert(portalDepth, 'selectioncontext') + options['lastBcUrl'] = toUrl(photoPath) + meth = getattr(photo, 'photo_view_ajax_template') + return meth(req, resp, **options) for i, uid in enumerate(selection) : - b = uidh.getBrain(uid) - size = b.getThumbnailSize - size = {'width':int(size['width']/2.0), 'height':int(size['height']/2.0)} - - if uid == photouid : - className = 'selected displayed' - posOfPhoto = i - else : - className = 'selected' - - path = b.getPath().split('/') - path.insert(portalDepth, 'selectioncontext') - - d = {'src': '%s/getThumbnail' % b.getURL() - ,'href': toUrl(path) - ,'thumbSize': size - ,'title' : b.Title - ,'className': className - , 'index': i - } - infos.append(d) + b = uidh.getBrain(uid) + size = b.getThumbnailSize + size = {'width':int(size['width']/2.0), 'height':int(size['height']/2.0)} + + if uid == photouid : + className = 'selected displayed' + posOfPhoto = i + else : + className = 'selected' + + path = b.getPath().split('/') + path.insert(portalDepth, 'selectioncontext') + + d = {'src': '%s/getThumbnail' % b.getURL() + ,'href': toUrl(path) + ,'thumbSize': size + ,'title' : b.Title + ,'className': className + , 'index': i + } + infos.append(d) if posOfPhoto > 0 : - previous = infos[posOfPhoto - 1]['href'] + previous = infos[posOfPhoto - 1]['href'] else : - previous = infos[0]['href'] + previous = infos[0]['href'] if posOfPhoto < len(infos) -1 : - next = infos[posOfPhoto + 1]['href'] + next = infos[posOfPhoto + 1]['href'] else : - next = infos[-1]['href'] + next = infos[-1]['href'] contextInfos = {'infos':infos, - 'isSelected':True, - 'backUrl' : '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize), - 'index' : posOfPhoto, - 'previous' : previous, - 'next' : next, - 'reBaseCtxUrl':'/^%s/' % (portal_url+'/selectioncontext/').replace('/', '\/'), - 'canonicalUrl': "'%s/'" % portal_url} + 'isSelected':True, + 'backUrl' : '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize), + 'index' : posOfPhoto, + 'previous' : previous, + 'next' : next, + 'reBaseCtxUrl':'/^%s/' % (portal_url+'/selectioncontext/').replace('/', '\/'), + 'canonicalUrl': "'%s/'" % portal_url} options['contextInfos'] = contextInfos # breadcrumbs customization if selectionIsLightbox : - lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) + lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) else : - lastBcTitle = _('My selection') + lastBcTitle = _('My selection') breadcrumbs = [ - { 'id' : 'root' - , 'title' : portal.title - , 'url' : portal_url}, - - {'id' : 'selection_view' - ,'title' : lastBcTitle - , 'url' : selectionUrl}, - - {'id' : photo.getId() - ,'title' : photo.title_or_id() - , 'url' : req.ACTUAL_URL} - ] + { 'id' : 'root' + , 'title' : portal.title + , 'url' : portal_url}, + + {'id' : 'selection_view' + ,'title' : lastBcTitle + , 'url' : selectionUrl}, + + {'id' : photo.getId() + ,'title' : photo.title_or_id() + , 'url' : req.ACTUAL_URL} + ] options['breadcrumbs'] = breadcrumbs -- 2.20.1