Création macro « thumbnails » qui ne comprend que les slides.
[Portfolio.git] / skins / getPhotoInfo.py
1 ##parameters=
2 from Products.CMFCore.utils import getToolByName
3 from Products.CMFCore.permissions import ReviewPortalContent, ModifyPortalContent
4 mtool = getToolByName(context, 'portal_membership')
5 pptool = getToolByName(context, 'portal_photo_print', None)
6 uidtool = getToolByName(context, 'portal_uidhandler')
7
8 features = {}
9 def toggleSelection(o, selected) :
10 if selected :
11 return '%s/remove_to_selection' % o.absolute_url()
12 else :
13 return '%s/add_to_selection' % o.absolute_url()
14
15 features['select'] = toggleSelection
16 features['cart'] = lambda o : '%s/get_slide_buyable_items' % o.absolute_url()
17
18 if mtool.checkPermission(ReviewPortalContent, context) :
19 features['hideAnonymous'] = True
20 if mtool.checkPermission(ModifyPortalContent, context) :
21 features['checkbox'] = True
22
23
24 sd = context.session_data_manager.getSessionData(create = 1)
25 selDict = sd.get('objects_selection_dict', {})
26 cart = sd.get('cart', None)
27
28 p = context
29 className = ''
30 uid = getattr(p, 'cmf_uid', None)
31 if uid is not None :
32 uid = uid()
33 absUrl = p.absolute_url()
34 selected = selDict.has_key(uid)
35 hiddenForAnonymous = p.hiddenForAnonymous()
36 if pptool :
37 buyable = bool(pptool.getPrintingOptionsFor(p))
38 if cart and cart.locked :
39 buyable = False
40 else :
41 buyable = False
42
43 if selected :
44 className = 'selected'
45 if hiddenForAnonymous :
46 className = 'hidden-slide'
47
48 d = {'href' : absUrl
49 ,'thumbUrl' : '%s/getThumbnail' % absUrl
50 ,'thumbSize': p.getThumbnailSize()
51 ,'title' : ('%s - %s' % (p.Title(), p.Description())).strip(' -')
52 ,'selected' : selected
53 ,'hiddenForAnonymous' : hiddenForAnonymous
54 ,'cmf_uid' : uidtool.register(p)
55 ,'buyable' : buyable
56 ,'className': className
57 ,'o' : p
58 }
59
60 return {'info' : d, 'features' : features}