Merge lp:~canonical-isd-hackers/canonical-identity-provider/unify-new-account-emails into lp:canonical-identity-provider/release

Proposed by Łukasz Czyżykowski
Status: Merged
Merged at revision: 115
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/unify-new-account-emails
Merge into: lp:canonical-identity-provider/release
Diff against target: 103 lines (+40/-11)
4 files modified
identityprovider/models/authtoken.py (+5/-4)
identityprovider/templates/ubuntu/email/newuser.txt (+7/-6)
identityprovider/tests/test_models_authtoken.py (+27/-0)
identityprovider/webservice/models.py (+1/-1)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/unify-new-account-emails
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve
Review via email: mp+33894@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Anthony Lenton (elachuni) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'identityprovider/models/authtoken.py'
2--- identityprovider/models/authtoken.py 2010-08-23 12:36:31 +0000
3+++ identityprovider/models/authtoken.py 2010-08-27 12:46:45 +0000
4@@ -126,14 +126,15 @@
5 subject = u"%s: %s" % (current_brand.name, _("Forgotten Password"))
6 self._send_email(from_name, subject, message)
7
8- def sendNewUserEmail(self):
9+ def sendNewUserEmail(self, template='newuser.txt'):
10 replacements = {
11 'token': self.token,
12- 'token_url': self.get_absolute_url()
13+ 'token_url': self.get_absolute_url(),
14+ 'toaddress': self.email,
15 }
16 from_name = unicode(current_brand.name)
17- message = render_to_string('%s/email/newuser.txt' %
18- current_brand.template_dir, replacements)
19+ template_path = '%s/email/%s' % (current_brand.template_dir, template)
20+ message = render_to_string(template_path, replacements)
21 subject = u"%s: %s" % (current_brand.name,
22 _("Finish your registration"))
23 self._send_email(from_name, subject, message)
24
25=== renamed file 'identityprovider/templates/ubuntu/email/api-email-validation-token.txt' => 'identityprovider/templates/ubuntu/email/api-newuser.txt'
26=== modified file 'identityprovider/templates/ubuntu/email/newuser.txt'
27--- identityprovider/templates/ubuntu/email/newuser.txt 2010-07-15 22:20:43 +0000
28+++ identityprovider/templates/ubuntu/email/newuser.txt 2010-08-27 12:46:45 +0000
29@@ -1,7 +1,7 @@
30 {% load i18n %}
31 {% blocktrans %}Hello
32
33-Thank you for registering with the Ubuntu Single Sign On service.
34+As a final step of the Ubuntu Single Sign On (SSO) account creation process, please validate the email address {{ toaddress }}. Ubuntu SSO enables convenient access to a variety of Ubuntu-related services like Ubuntu One with the same username and password.
35
36 Here is your confirmation code:
37
38@@ -11,8 +11,9 @@
39
40 {{ token_url }}
41
42-If you don't know what this is about, then someone has probably entered your email address by mistake at the Ubuntu Single Sign On service web site. Sorry about that. You don't need to do anything further, just delete this message.
43-
44-Regards,
45-
46-The Ubuntu Single Sign On team{% endblocktrans %}
47+If you don't know what this is about, then someone has probably entered your email address by mistake. Sorry about that. You don't need to do anything further. Just delete this message.
48+
49+Thank you,
50+
51+The Ubuntu Single Sign On team
52+https://login.ubuntu.com/{% endblocktrans %}
53
54=== modified file 'identityprovider/tests/test_models_authtoken.py'
55--- identityprovider/tests/test_models_authtoken.py 2010-08-23 12:36:31 +0000
56+++ identityprovider/tests/test_models_authtoken.py 2010-08-27 12:46:45 +0000
57@@ -66,6 +66,33 @@
58
59 self._teardown_mock_render_to_string(rts)
60
61+ def test_sendNewUserEmail_uses_provided_template(self):
62+ token = self._get_new_account_token()
63+ mock_rts, rts = self._setup_mock_rendert_to_string()
64+
65+ token.sendNewUserEmail('new-template.txt')
66+
67+ self.assertTrue(mock_rts.template.endswith('new-template.txt'))
68+
69+ self._teardown_mock_render_to_string(rts)
70+
71+ def test_sendNewUserEmail_default_template(self):
72+ token = self._get_new_account_token()
73+ mock_rts, rts = self._setup_mock_rendert_to_string()
74+
75+ token.sendNewUserEmail()
76+
77+ self.assertTrue(mock_rts.template.endswith('newuser.txt'))
78+
79+ self._teardown_mock_render_to_string(rts)
80+
81+ def _get_new_account_token(self):
82+ account = Account.objects.get_by_email('test@canonical.com')
83+ token = AuthTokenFactory().new(account, 'test@cannical.com',
84+ 'test@canonical.com',
85+ LoginTokenType.NEWACCOUNT, None)
86+ return token
87+
88 def _teardown_mock_render_to_string(self, rts):
89 authtoken.render_to_string = rts
90
91
92=== modified file 'identityprovider/webservice/models.py'
93--- identityprovider/webservice/models.py 2010-08-23 20:09:44 +0000
94+++ identityprovider/webservice/models.py 2010-08-27 12:46:45 +0000
95@@ -249,7 +249,7 @@
96 token = AuthTokenFactory().new_api_email_validation_token(
97 account, cleaned_data['email'])
98
99- token.sendEmailValidationToken('api-email-validation-token.txt')
100+ token.sendNewUserEmail('api-newuser.txt')
101
102 account_created.send(sender=self,
103 openid_identifier=account.openid_identifier)