aec90438f72af0ae18cc0e0f13cf39b4a7ba4d5b
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.Plinn
.PloneMisc
import Batch
4 from Products
.Portfolio
.utils
import translate
5 def _(message
) : return translate(message
, context
).encode('utf-8')
7 uidh
= getToolByName(context
, 'portal_uidhandler')
8 utool
= getToolByName(context
, 'portal_url')
9 pptool
= getToolByName(context
, 'portal_photo_print', None)
10 portal
= utool
.getPortalObject()
12 portalDepth
= len(portal
.getPhysicalPath())
14 toUrl
= req
.physicalPathToURL
16 # check if a lightbox is currently selected
17 lightboxpath
= req
.SESSION
.get('lightboxpath', None)
18 selectionIsLightbox
= False
19 if lightboxpath
is None :
20 selection
= req
.SESSION
.get('objects_selection', [])
23 lightbox
= portal
.restrictedTraverse(lightboxpath
)
24 selection
= lightbox
.getUidList()
25 selectionIsLightbox
= True
27 req
.SESSION
.set('lightboxpath', None)
28 selection
= req
.SESSION
.get('objects_selection', [])
30 start
= req
.get('b_start', 0)
31 brains
= [uidh
.getBrain(uid
) for uid
in selection
]
32 batch
= Batch(brains
, context
.default_batch_size
, start
, orphan
=1, quantumleap
=1)#, b_start_str='pho_start')
33 cart
= req
.SESSION
.get('cart', None)
36 for index
, b
in enumerate(batch
) :
37 path
= b
.getPath().split('/')
38 path
.insert(portalDepth
, 'selectioncontext')
41 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
42 if cart
and cart
.locked
:
47 d
= {'href': toUrl('/'.join(path
))
48 ,'thumbUrl' : '%s/getThumbnail' % b
.getURL()
49 ,'thumbSize' : b
.getThumbnailSize
50 ,'title' : ('%s - %s' % (b
.Title
, b
.Description
)).strip(' -')
59 features
['del'] = lambda b
: '%s/remove_to_selection' % b
.getURL()
60 features
['cart'] = lambda b
: '%s/get_slide_buyable_items' % b
.getURL()
62 # breadcrumbs customization
63 if selectionIsLightbox
:
64 lastBcTitle
= '%s (%s)' % (_('My selection'), lightbox
.title_or_id())
66 lastBcTitle
= _('My selection')
69 , 'title' : portal
.title
70 , 'url' : portal_url
},
72 {'id' : 'selection_view'
73 ,'title' : lastBcTitle
74 , 'url' : '%s/selection_view' % portal_url
}
79 options
['infos'] = infos
80 options
['batch'] = batch
81 options
['features'] = features
83 options
['container_type'] = 'selection'
84 options
['selectionIsLightbox'] = selectionIsLightbox
85 options
['breadcrumbs'] = breadcrumbs
87 if selectionIsLightbox
:
88 options
['lightbox'] = lightbox
90 options
['selectionName'] = 'not saved yet'
92 return context
.selection_view_template(**options
)