29477788abd87f3ae099710efc9cdeaed18f728a
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.CMFCore
.permissions
import ReviewPortalContent
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
21 sd
= context
.session_data_manager
.getSessionData(create
= 1)
22 selDict
= sd
.get('objects_selection_dict', {})
23 cart
= sd
.get('cart', None)
27 uid
= getattr(p
, 'cmf_uid', None)
30 absUrl
= p
.absolute_url()
31 selected
= selDict
.has_key(uid
)
32 hiddenForAnonymous
= p
.hiddenForAnonymous()
34 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
35 if cart
and cart
.locked
:
41 className
= 'selected'
42 if hiddenForAnonymous
:
43 className
= 'hidden-slide'
46 ,'thumbUrl' : '%s/getThumbnail' % absUrl
47 ,'thumbSize': p
.getThumbnailSize()
48 ,'title' : ('%s - %s' % (p
.Title(), p
.Description())).strip(' -')
49 ,'selected' : selected
50 ,'hiddenForAnonymous' : hiddenForAnonymous
51 ,'cmf_uid' : uidtool
.register(p
)
53 ,'className': className
57 return {'info' : d
, 'features' : features
}