Ajout du minimum pour que zope démarre sans paypal installé.
[photoprint.git] / skins / customer_join_form.py
1 ##parameters=add=''
2 from Products.CMFCore.utils import getToolByName
3 from Products.realis.utils import translate
4 from ZTUtils import make_query as mq
5 _ = lambda msg : translate(msg, context)
6 ptool = getToolByName(script, 'portal_properties')
7 atool = getToolByName(script, 'portal_actions')
8 validate_email = ptool.getProperty('validate_email')
9 options = {}
10 options['validate_email'] = validate_email
11
12 req = context.REQUEST
13 resp = req.RESPONSE
14 form = req.form
15 fg = lambda name : form.get(name,'').strip()
16
17
18 if add and \
19 context.validatePassword(**form) and \
20 context.customer_add_control(**form) :
21 came_from = fg('came_from')
22 if came_from :
23 return context.setRedirect( atool, 'user/logged_in'
24 , came_from = came_from
25 , __ac_name=fg('member_id')
26 , __ac_password=fg('password'))
27 #return resp.redirect('%s?%s' % ( came_from, mq(__ac_name=fg('member_id'), __ac_password=fg('password'), noajax='1')) )
28 else:
29 options['member_id'] = fg('member_id')
30 options['password'] = fg('password')
31 options['form_action'] = target = atool.getActionInfo('user/logged_in')['url']
32 return context.confirm_join_template(**options)
33
34 continuationFields = [
35 'given_name'
36 , 'name'
37 , 'member_email'
38 , 'member_id'
39 , 'password'
40 , 'confirm'
41 , 'send_password'
42 , 'billing_address'
43 , 'billing_city'
44 , 'billing_zipcode'
45 , 'country'
46 , 'phone'
47 , 'accept_gcs']
48
49
50 for name in continuationFields :
51 options[name] = fg(name)
52
53 # TODO try to be more clever...
54 if not options['country']:
55 options['country'] = 'FR'
56 options['came_from'] = fg('came_from')
57 return context.customer_join_template(**options)