2 from Products
.Plinn
.PloneMisc
import Batch
3 from Products
.CMFCore
.utils
import getToolByName
4 from Products
.CMFCore
.permissions
import ReviewPortalContent
, ModifyPortalContent
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
21 if mtool
.checkPermission(ModifyPortalContent
, context
) :
22 features
['checkbox'] = True
25 pho_start
= req
.get('pho_start', 0)
26 batch
= Batch(portfolio
.listNearestFolderContents(contentFilter
={'portal_type' : ['Photo']}, sorted=True),
27 context
.default_batch_size
, pho_start
, orphan
=5, quantumleap
=1, b_start_str
='pho_start')
31 sd
= context
.session_data_manager
.getSessionData(create
= 1)
32 selDict
= sd
.get('objects_selection_dict', {})
33 cart
= sd
.get('cart', None)
37 uid
= getattr(p
, 'cmf_uid', None)
40 absUrl
= p
.absolute_url()
41 selected
= selDict
.has_key(uid
)
42 hiddenForAnonymous
= p
.hiddenForAnonymous()
44 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
45 if cart
and cart
.locked
:
51 className
= 'selected'
52 if hiddenForAnonymous
:
53 className
= 'hidden-slide'
56 ,'thumbUrl' : '%s/getThumbnail' % absUrl
57 ,'thumbSize': p
.getThumbnailSize()
58 ,'title' : ('%s - %s' % (p
.Title(), p
.Description())).strip(' -')
59 ,'selected' : selected
60 ,'hiddenForAnonymous' : hiddenForAnonymous
61 ,'cmf_uid' : uidtool
.register(p
)
63 ,'className': className
68 return {'infos':infos
, 'batch':batch
, 'features':features
}