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
= req
.get('pho_start', 0)
26 sort_on
, sort_order
= context
.getDefaultSorting()
27 contentFilter
= {'portal_type' : ['Photo'],
29 'sort_order' : sort_order
}
30 batch
= Batch(portfolio
.listCatalogedContents(contentFilter
=contentFilter
),
31 context
.default_batch_size
, pho_start
, orphan
=5, quantumleap
=1, b_start_str
='pho_start')
35 sd
= context
.session_data_manager
.getSessionData(create
= 1)
36 selDict
= sd
.get('objects_selection_dict', {})
37 cart
= sd
.get('cart', None)
41 uid
= getattr(p
, 'cmf_uid', None)
42 # if uid is not None :
45 selected
= selDict
.has_key(uid
)
46 hiddenForAnonymous
= p
.hiddenForAnonymous
48 buyable
= bool(pptool
.getPrintingOptionsFor(p
.getObject()))
49 if cart
and cart
.locked
:
55 className
= 'selected'
56 if hiddenForAnonymous
:
57 className
= 'hidden-slide'
60 ,'thumbUrl' : '%s/getThumbnail' % absUrl
61 ,'thumbSize': p
.getThumbnailSize
62 ,'title' : ('%s - %s' % (p
.Title
, p
.Description
)).strip(' -')
63 ,'selected' : selected
64 ,'hiddenForAnonymous' : hiddenForAnonymous
65 ,'cmf_uid' : uidtool
.register(p
)
67 ,'className': className
72 return {'infos':infos
,
75 'sorting' : {'sort_on' : sort_on
,
76 'sort_order' : sort_order
}