1 ##parameters=portfolio, pho_start=None, batch_size=None
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
.getURL()
14 return '%s/add_to_selection' % o
.getURL()
16 features
['select'] = toggleSelection
17 features
['cart'] = lambda o
: '%s/get_slide_buyable_items' % o
.getURL()
19 if mtool
.checkPermission(ReviewPortalContent
, context
) :
20 features
['hideAnonymous'] = True
21 if mtool
.checkPermission(ModifyPortalContent
, context
) :
22 features
['checkbox'] = True
25 pho_start
= pho_start
if pho_start
is not None else 0
26 batch_size
= batch_size
if batch_size
is not None else context
.default_batch_size
27 sort_on
, sort_order
= context
.getDefaultSorting()
28 contentFilter
= {'portal_type' : ['Photo'],
30 'sort_order' : sort_order
}
31 batch
= Batch(portfolio
.listCatalogedContents(contentFilter
=contentFilter
),
32 batch_size
, pho_start
, quantumleap
=1, b_start_str
='pho_start')
36 sd
= context
.session_data_manager
.getSessionData(create
= 1)
37 selDict
= sd
.get('objects_selection_dict', {})
38 cart
= sd
.get('cart', None)
42 uid
= getattr(p
, 'cmf_uid', None)
43 # if uid is not None :
46 selected
= selDict
.has_key(uid
)
47 hiddenForAnonymous
= p
.hiddenForAnonymous
49 buyable
= bool(pptool
.getPrintingOptionsFor(p
.getObject()))
50 if cart
and cart
.locked
:
56 className
= 'selected'
57 if hiddenForAnonymous
:
58 className
= 'hidden-slide'
61 ,'thumbUrl' : '%s/getThumbnail' % absUrl
62 ,'thumbSize': p
.getThumbnailSize
63 ,'title' : ('%s - %s' % (p
.Title
, p
.Description
)).strip(' -')
64 ,'selected' : selected
65 ,'hiddenForAnonymous' : hiddenForAnonymous
66 ,'cmf_uid' : uidtool
.register(p
)
68 ,'className': className
73 return {'infos':infos
,
76 'sorting' : {'sort_on' : sort_on
,
77 'sort_order' : sort_order
}