Merge lp:~canonical-isd-hackers/canonical-identity-provider/bug_495006 into lp:canonical-identity-provider/release

Proposed by David Owen
Status: Merged
Merged at revision: 48
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/bug_495006
Merge into: lp:canonical-identity-provider/release
Diff against target: 108 lines (+45/-8)
4 files modified
doctests/stories/sso-server/prefilled-email.txt (+29/-0)
identityprovider/templates/launchpad/registration/login.html (+2/-2)
identityprovider/templates/ubuntu/registration/login.html (+2/-2)
identityprovider/views/ui.py (+12/-4)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/bug_495006
Reviewer Review Type Date Requested Status
Danny Tamez (community) Approve
Review via email: mp+25804@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Danny Tamez (zematynnad) wrote :

Great job David

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'doctests/stories/sso-server/prefilled-email.txt'
2--- doctests/stories/sso-server/prefilled-email.txt 1970-01-01 00:00:00 +0000
3+++ doctests/stories/sso-server/prefilled-email.txt 2010-05-21 21:14:29 +0000
4@@ -0,0 +1,29 @@
5+Copyright 2010 Canonical Ltd. This software is licensed under the
6+GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+= Pre-fill e-mail addresses on forms =
9+
10+If the user has attempted a login (and failed), we would like to use
11+the e-mail provided to pre-fill other forms.
12+
13+== "Forgot Password" form ==
14+
15+ >>> browser = setupBrowser()
16+ >>> browser.open('http://openid.launchpad.dev')
17+ >>> browser.getControl(name='email').value = 'new-user@example.com'
18+ >>> browser.getControl(name='continue').click()
19+ >>> browser.getLink('Forgot your password?').click()
20+ >>> print browser.getControl(name='email').value
21+ new-user@example.com
22+
23+
24+== "New Account" form ==
25+
26+ >>> browser = setupBrowser()
27+ >>> browser.open('http://openid.launchpad.dev')
28+ >>> browser.getControl(name='email').value = 'new-user@example.com'
29+ >>> browser.getControl(name='continue').click()
30+ >>> browser.getLink('New account').click()
31+ >>> print browser.getControl(name='email').value
32+ new-user@example.com
33+
34
35=== modified file 'identityprovider/templates/launchpad/registration/login.html'
36--- identityprovider/templates/launchpad/registration/login.html 2010-05-13 16:01:26 +0000
37+++ identityprovider/templates/launchpad/registration/login.html 2010-05-21 21:14:29 +0000
38@@ -39,12 +39,12 @@
39 {% if form.non_field_errors %}<span class="error">{{ form.non_field_errors|join:"" }}</span>{% endif %}
40 <br />
41 {% if not readonly %}
42- <a href="+forgot_password" id="forgotpw-link">{% trans "Forgot your password?" %}</a>
43+ <a href="+forgot_password{% if form.email.data %}?email={{ form.email.data|urlencode }}{% endif %}" id="forgotpw-link">{% trans "Forgot your password?" %}</a>
44 {% endif %}
45 </p>
46 {% if not readonly %}
47 <p>
48- <a href="+new_account" class="btn alt"><span><span>{% trans "Create a new account" %}</span></span></a>
49+ <a href="+new_account{% if form.email.data %}?email={{ form.email.data|urlencode }}{% endif %}" class="btn alt"><span><span>{% trans "Create a new account" %}</span></span></a>
50 </p>
51 {% endif %}
52 <div class="actions">
53
54=== modified file 'identityprovider/templates/ubuntu/registration/login.html'
55--- identityprovider/templates/ubuntu/registration/login.html 2010-05-13 16:01:26 +0000
56+++ identityprovider/templates/ubuntu/registration/login.html 2010-05-21 21:14:29 +0000
57@@ -44,7 +44,7 @@
58 {% if form.non_field_errors %}<span class="error">{{ form.non_field_errors|join:"" }}</span>{% endif %}
59 <br />
60 {% if not readonly %}
61- <a href="+forgot_password" id="forgotpw-link">{% trans "Forgot your password?" %}</a>
62+ <a href="+forgot_password{% if form.email.data %}?email={{ form.email.data|urlencode }}{% endif %}" id="forgotpw-link">{% trans "Forgot your password?" %}</a>
63 {% endif %}
64 </p>
65
66@@ -73,7 +73,7 @@
67 </p>
68 {% if not readonly %}
69 <p>
70- <a href="+new_account" class="btn alt"><span><span>{% trans "New account" %}</span></span></a>
71+ <a href="+new_account{% if form.email.data %}?email={{ form.email.data|urlencode }}{% endif %}" class="btn alt"><span><span>{% trans "New account" %}</span></span></a>
72 </p>
73 {% endif %}
74 {% endblock %}
75
76=== modified file 'identityprovider/views/ui.py'
77--- identityprovider/views/ui.py 2010-05-13 16:01:26 +0000
78+++ identityprovider/views/ui.py 2010-05-21 21:14:29 +0000
79@@ -123,8 +123,12 @@
80 @guest_required
81 @check_readonly
82 def new_account(request, token=None):
83- form = NewAccountForm()
84- if request.method == 'POST':
85+ if request.method == 'GET':
86+ if 'email' in request.GET:
87+ form = NewAccountForm(initial={'email': request.GET['email']})
88+ else:
89+ form = NewAccountForm()
90+ elif request.method == 'POST':
91 form = NewAccountForm(request.POST)
92 if form.is_valid():
93
94@@ -330,8 +334,12 @@
95 @guest_required
96 @check_readonly
97 def forgot_password(request, token=None):
98- form = ForgotPasswordForm()
99- if request.method == 'POST':
100+ if request.method == 'GET':
101+ if 'email' in request.GET:
102+ form = ForgotPasswordForm(initial={'email': request.GET['email']})
103+ else:
104+ form = ForgotPasswordForm()
105+ elif request.method == 'POST':
106 form = ForgotPasswordForm(request.POST)
107 if form.is_valid():
108 response = _verify_captcha_response(