Merge lp:~nigelbabu/summit/validate-lp-name into lp:~summit-hackers/summit/1.x

Proposed by Nigel Babu
Status: Merged
Approved by: Michael Hall
Approved revision: 142
Merged at revision: 143
Proposed branch: lp:~nigelbabu/summit/validate-lp-name
Merge into: lp:~summit-hackers/summit/1.x
Diff against target: 21 lines (+11/-0)
1 file modified
summit/sponsor/forms.py (+11/-0)
To merge this branch: bzr merge lp:~nigelbabu/summit/validate-lp-name
Reviewer Review Type Date Requested Status
Michael Hall (community) Approve
Review via email: mp+72229@code.launchpad.net

Commit message

Validate the launchpad username so we don't barf when the username doesn't exit.

To post a comment you must log in.
Revision history for this message
Michael Hall (mhall119) wrote :

I added a test which uses the actual launchpad services. Not ideal, but it at least tests it

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/sponsor/forms.py'
2--- summit/sponsor/forms.py 2011-03-21 19:41:45 +0000
3+++ summit/sponsor/forms.py 2011-08-19 17:15:23 +0000
4@@ -105,6 +105,17 @@
5 '''A Sponsorship form for suggesting someone else for sponsorship.'''
6 launchpad_name = forms.CharField(label='Launchpad Username')
7
8+ def clean_launchpad_name(self):
9+ data = self.cleaned_data['launchpad_name']
10+ launchpad = Launchpad.login("Summit", "", "", EDGE_SERVICE_ROOT,
11+ settings.LAUNCHPAD_CACHE)
12+ name = None
13+ try:
14+ name = launchpad.people[data].display_name
15+ except KeyError:
16+ raise forms.ValidationError("%s is not a valid user on Launchpad" %
17+ data)
18+ return data
19
20 PARTICIPATION_CHOICES = [
21 ("not", "I am NOT interested in this idea"),

Subscribers

People subscribed via source and target branches

to all changes: