Désactivation d'options obsolètes.
[photoprint.git] / skins / customer_join_form.py
1 ##parameters=add=''
2 from Products.CMFCore.utils import getToolByName
3 from Products.Plinn.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 , 'collection_id'
43 , 'collection_password'
44 , 'collection_password_confirm'
45 , 'billing_address'
46 , 'billing_city'
47 , 'billing_zipcode'
48 , 'country'
49 , 'phone']
50
51
52 for name in continuationFields :
53 options[name] = fg(name)
54
55 # TODO try to be more clever...
56 if not options['country']:
57 options['country'] = 'FR'
58 options['came_from'] = fg('came_from')
59 return context.customer_join_template(**options)