00cd2958618de0d715c3aa0cb73be2778eae1eba
2 from Products
.Plinn
.PloneMisc
import Batch
3 from Products
.CMFCore
.utils
import getToolByName
4 from Products
.CMFCore
.permissions
import ReviewPortalContent
5 mtool
= getToolByName(context
, 'portal_membership')
6 pptool
= getToolByName(context
, 'portal_photo_print', None)
7 uidtool
= getToolByName(context
, 'portal_uidhandler')
10 def toggleSelection(o
, selected
) :
12 return '%s/remove_to_selection' % o
.absolute_url()
14 return '%s/add_to_selection' % o
.absolute_url()
16 features
['select'] = toggleSelection
17 features
['cart'] = lambda o
: '%s/get_slide_buyable_items' % o
.absolute_url()
19 if mtool
.checkPermission(ReviewPortalContent
, context
) :
20 features
['hideAnonymous'] = True
23 pho_start
= req
.get('pho_start', 0)
24 batch
= Batch(portfolio
.listNearestFolderContents(contentFilter
={'portal_type' : ['Photo']}, sorted=True),
25 50, pho_start
, orphan
=5, quantumleap
=1, b_start_str
='pho_start')
29 sd
= context
.session_data_manager
.getSessionData(create
= 1)
30 selDict
= sd
.get('objects_selection_dict', {})
31 cart
= sd
.get('cart', None)
35 uid
= getattr(p
, 'cmf_uid', None)
38 absUrl
= p
.absolute_url()
39 selected
= selDict
.has_key(uid
)
40 hiddenForAnonymous
= p
.hiddenForAnonymous()
42 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
43 if cart
and cart
.locked
:
49 className
= 'selected'
50 if hiddenForAnonymous
:
51 className
= 'hidden-slide'
54 ,'thumbUrl' : '%s/getThumbnail' % absUrl
55 ,'thumbSize': p
.getThumbnailSize()
56 ,'title' : ('%s - %s' % (p
.Title(), p
.Description())).strip(' -')
57 ,'selected' : selected
58 ,'hiddenForAnonymous' : hiddenForAnonymous
59 ,'cmf_uid' : uidtool
.register(p
)
61 ,'className': className
66 return {'infos':infos
, 'batch':batch
, 'features':features
}