On stagne pour l'instant : l'indexation par l'automate de tuilage des images est...
[Portfolio.git] / skins / shipping_set_control.py
1 ##parameters=**kw
2 from Products.Portfolio.utils import translate
3 _ = lambda msg : translate(msg, context)
4
5 kg = lambda name : kw.get(name, '').strip()
6
7 mandatoryFields = [
8 ('shipping_fullname', _('Please enter a name.'))
9 , ('shipping_address', _('Please enter an address.'))
10 , ('shipping_city', _('Please enter a city.'))
11 , ('shipping_zipcode', _('Please enter zip code.'))
12 , ('shipping_country', _('Please enter a country.'))
13 ]
14
15 shippingInfo = {}
16 for name, failMessage in mandatoryFields :
17 value = kg(name)
18 shippingInfo[name] = value
19 if not value :
20 return context.setStatus(False, failMessage)
21
22 session = context.REQUEST.SESSION
23 sg = session.get
24 cart = sg('cart', None)
25
26 if cart is None :
27 return context.setStatus(False, _('No cart found. Your session may have expired.'))
28
29 cart.setShippingInfo(**shippingInfo)
30 return context.setStatus(True, _('Shipping informations saved.'))