8280dbc3e9986acbb312589004d81029fcb2b2b2
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.photoprint
.utils
import translate
4 from Products
.CMFDefault
.utils
import translate
as cmf_translate
5 rtool
= getToolByName(context
, 'portal_registration')
6 ptool
= getToolByName(context
, 'portal_properties')
7 _
= lambda msg
: translate(msg
, context
)
9 kg
= lambda name
: kw
.get(name
, '').strip()
11 cmfprops
= {'username' : kg('member_id')
12 ,'email' : kg('member_email')}
14 failMessage
= rtool
.testPropertiesValidity(cmfprops
)
15 if failMessage
is not None :
16 return context
.setStatus(False, cmf_translate(failMessage
, context
))
19 ('given_name', _('Please enter a given name.'))
20 , ('name', _('Please enter a name.'))
21 , ('member_email', _('Please enter an email.'))
22 , ('member_id', _('Please enter a member id.'))
23 , ('billing_address', _('Please enter a billing address.'))
24 , ('billing_city', _('Please enter a city.'))
25 , ('billing_zipcode', _('Please enter zip code.'))
26 , ('country', _('Please enter a country.'))
27 , ('phone', _('Please enter a phone.'))
28 , ('accept_gcs', _('Please accept general conditions of sales.'))
31 for name
, failMessage
in mandatoryFields
:
34 return context
.setStatus(False, failMessage
)
38 rtool
.addMember( id=kg('member_id'),
39 password
=kg('password'),
40 properties
={'username' : kg('member_id')
41 ,'given_name' : kg('given_name')
43 ,'email' : kg('member_email')
44 ,'billing_address' : kg('billing_address')
45 ,'billing_city' : kg('billing_city')
46 ,'billing_zipcode' : kg('billing_zipcode')
47 ,'country' : kg('country')
48 ,'phone' : kg('phone')
49 ,'accept_gcs' : kg('accep_gcs')} )
50 except ValueError, errmsg
:
51 return context
.setStatus(False, _(errmsg
))
54 if kg('send_password') or ptool
.getProperty('validate_email') :
55 rtool
.registeredNotify(kg('member_id'))
57 return context
.setStatus(True, 'Success!')