style.
[Plinn.git] / skins / custom_generic / registered_notify_template.py
1 ##parameters= rtool, request, member=None, password='', email=''
2
3 #TODO : translate messages
4 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
5 #_ = MessageIDFactory('cmf_default')
6 _ = lambda x : lambda : x
7 from quopri import encodestring
8
9 portal = context.portal_url.getPortalObject()
10 mtool = portal.portal_membership
11
12
13 def convertMessage(msg) :
14 return msg.replace('${', '%(').replace('}', ')s')
15
16 def encodeAdr(member) :
17 name = member.getMemberFullName(nameBefore=0)
18 email = member.getProperty('email')
19 qpName = encodestring(name).replace('=\n', '')
20 return '''"=?utf-8?q?%s?=" <%s>''' % (qpName, email)
21
22 mfromName = portal.email_from_name
23 mfromEmail = portal.email_from_address
24 mfromQpName = encodestring(mfromName).replace('=\n', '')
25 mfrom = '''"=?utf-8?q?%s?=" <%s>''' % (mfromQpName, mfromEmail)
26
27 sender = mfrom
28 mto = encodeAdr(member)
29
30 subject = convertMessage(_("${portal_title}: Your Membership Information")()) % {'portal_title': portal.title}
31
32 text = []
33 pr = text.append
34
35 pr(convertMessage(_("You have been registered as a member of \"${portal_title}\", which allows you to personalize your view of the website and participate in the community.")()) % {'portal_title': portal.title})
36
37 if portal.description :
38 pr('')
39 pr(_("This describes the purpose of the website:")())
40 pr('')
41 pr(portal.description)
42
43 pr('')
44 pr(convertMessage(_("Visit us at ${portal_url}")()) % {'portal_url' : portal.absolute_url()})
45 pr('')
46 pr(convertMessage(_("Your member id and password are: Member ID: ${member_id} Password: ${password}")()) % {'member_id':member.getId(), 'password':password})
47 pr('')
48 pr(_("You can use this URL to log in:")())
49 pr('')
50
51 login_url = mtool.getActionInfo('user/login')['url']
52 pr(login_url)
53 pr('')
54
55 if len(login_url) > 70 :
56 pr(_("Be aware that this URL might wrap over two lines. If your browser shows an error message when you try to access the URL please make sure that you put in the complete string.")())
57
58 pr(mfromName+'.')
59
60 text = '\n'.join(text)
61
62 message = context.echange_mail_template( From = sender
63 , To = mto
64 , Subject = "=?utf-8?q?%s?=" % encodestring(subject).replace('=\n', '')
65 , ContentType = 'text/plain'
66 , charset = 'UTF-8'
67 , body= text
68 )
69 return message.encode('utf-8')