bb4391d7d43f783690cc968ba871ede7e647ef06
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')
9 def toggleSelection(o
, selected
) :
11 return '%s/remove_to_selection' % o
.absolute_url()
13 return '%s/add_to_selection' % o
.absolute_url()
15 features
['select'] = toggleSelection
16 features
['cart'] = lambda o
: '%s/get_slide_buyable_items' % o
.absolute_url()
18 if mtool
.checkPermission(ReviewPortalContent
, context
) :
19 features
['hideAnonymous'] = True
20 if mtool
.checkPermission(ModifyPortalContent
, context
) :
21 features
['checkbox'] = True
24 sd
= context
.session_data_manager
.getSessionData(create
= 1)
25 selDict
= sd
.get('objects_selection_dict', {})
26 cart
= sd
.get('cart', None)
30 uid
= getattr(p
, 'cmf_uid', None)
33 absUrl
= p
.absolute_url()
34 selected
= selDict
.has_key(uid
)
35 hiddenForAnonymous
= p
.hiddenForAnonymous()
37 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
38 if cart
and cart
.locked
:
44 className
= 'selected'
45 if hiddenForAnonymous
:
46 className
= 'hidden-slide'
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
)
56 ,'className': className
60 return {'info' : d
, 'features' : features
}