maniaquerie
[photoprint.git] / skins / order_printing_list.py
1 ##parameters=
2 from Products.CMFCore.utils import getToolByName
3 from Products.CMFCore.exceptions import zExceptions_Unauthorized
4 uidh = getToolByName(context, 'portal_uidhandler')
5 options = {}
6
7 infos = []
8 for item in context.items :
9 try :
10 b = uidh.getBrain(item['cmf_uid'])
11 except : # TODO: catch only UniqueIdError (not public yet:)
12 raise zExceptions_Unauthorized
13 size = b.getThumbnailSize
14 d = {'thumbUrl' : '%s/getThumbnail' % b.getURL()
15 ,'thumbHeight' : size['height'] / 2
16 ,'thumbWidth' : size['width'] / 2
17 ,'alt' : ('%s - %s' % (b.Title, b.Description)).strip(' -')
18 ,'title' : item['title']
19 ,'description' : item['description']
20 ,'unit_price' : item['unit_price']
21 ,'quantity' : item['quantity']
22 ,'total' : item['unit_price'] * item['quantity']
23 ,'url' : b.getURL()
24 ,'id' : b.getId
25 }
26 infos.append(d)
27
28 options['infos'] = infos
29 if traverse_subpath and traverse_subpath[-1] == 'xml' :
30 channel_info = {'title' :'Commande %s' % context.getId()
31 ,'url' : context.absolute_url()
32 ,'description' :'' # TODO mettre l'identification client
33 , }
34
35 options['channel_info'] = channel_info
36 options['listItemInfos'] = infos
37 return context.order_printing_list_template_xml(**options)
38 else :
39 return context.order_printing_list_template(**options)