Résolu : problème de localisation avec zope-2.12.
[photoprint.git] / skins / order_view.py
1 ##parameters=
2 from Products.CMFCore.utils import getToolByName
3 from Products.photoprint.price import Price
4 from Products.photoprint.cart import PrintCart
5 uidh = getToolByName(context, 'portal_uidhandler')
6 wtool = getToolByName(context, 'portal_workflow')
7
8 options = {}
9
10 quantity = 0
11 prices = []
12 infos = []
13
14 session = context.REQUEST.SESSION
15 sg = session.get
16 cart = sg('cart', PrintCart())
17 wfstate = wtool.getInfoFor(context, 'review_state', 'order_workflow')
18 options['wfstate'] = wfstate
19 options['wfhistory'] = wtool.getInfoFor(context, 'review_history', 'order_workflow')
20 toBePaid = wfstate == 'recorded'
21
22 if toBePaid :
23 paymentRequest = context.getPaymentRequest()
24 options['paymentRequest'] = paymentRequest
25
26 if cart.locked and \
27 cart.pendingOrderPath == context.getPhysicalPath() :
28 options['orderIsCart'] = True
29 if wfstate != 'recorded' :
30 cart = PrintCart()
31 session['cart'] = cart
32 else :
33 options['orderIsCart'] = False
34
35 for item in context.items :
36 d = {'title' : item['title']
37 ,'description' : item['description']
38 ,'unit_price' : item['unit_price']
39 ,'quantity' : item['quantity']
40 ,'total' : item['unit_price'] * item['quantity']
41 }
42
43 b = uidh.queryBrain(item['cmf_uid'])
44 if b :
45 size = b.getThumbnailSize
46 thumbInfo = {'thumbUrl' : '%s/getThumbnail' % b.getURL()
47 ,'thumbHeight' : size['height'] / 2
48 ,'thumbWidth' : size['width'] / 2
49 ,'alt' : ('%s - %s' % (b.Title, b.Description)).strip(' -')
50 }
51 d.update(thumbInfo)
52 quantity += d['quantity']
53 prices.append(d['total'])
54 infos.append(d)
55
56 options['infos'] = infos
57 options['quantity'] = quantity
58 options['pricesSum'] = context.price
59 options['shippingFees'] = shippingFees = context.shippingFees
60 options['total'] = context.amountWithFees
61
62 return context.order_view_template(**options)