Simplifications. On vire le pictogramme du cadenas : personne ne savait à quoi ça...
[Plinn.git] / skins / photo_theme / 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) and \
21 context.validatePrivateAccess(**form) :
22 came_from = fg('came_from')
23 if came_from :
24 return context.setRedirect( atool, 'user/logged_in'
25 , came_from = came_from
26 , __ac_name=fg('member_id')
27 , __ac_password=fg('password'))
28 #return resp.redirect('%s?%s' % ( came_from, mq(__ac_name=fg('member_id'), __ac_password=fg('password'), noajax='1')) )
29 else:
30 options['member_id'] = fg('member_id')
31 options['password'] = fg('password')
32 options['form_action'] = target = atool.getActionInfo('user/logged_in')['url']
33 return context.confirm_join_template(**options)
34
35 continuationFields = [
36 'given_name'
37 , 'name'
38 , 'member_email'
39 , 'member_id'
40 , 'password'
41 , 'confirm'
42 , 'send_password'
43 , 'wedding_id'
44 , 'wedding_password'
45 , 'wedding_password_confirm'
46 , 'billing_address'
47 , 'billing_city'
48 , 'billing_zipcode'
49 , 'country'
50 , 'phone'
51 , 'accept_gcs']
52
53
54 for name in continuationFields :
55 options[name] = fg(name)
56
57 # TODO try to be more clever...
58 if not options['country']:
59 options['country'] = 'FR'
60 options['came_from'] = fg('came_from')
61 return context.customer_join_template(**options)