Add lookup by email address

This commit is contained in:
2010-07-08 09:46:23 +01:00
parent 93c86404d0
commit 3dea1a8d24
2 changed files with 4 additions and 1 deletions

View File

@@ -92,7 +92,8 @@ class UserLookupForm(forms.Form):
choices = [ (1, "Auth Username"),
(2, "Character"),
(3, "Reddit ID") ]
(3, "Reddit ID"),
(4, "Email Address"), ]
type = forms.ChoiceField(label = u'Search type', choices = choices)
username = forms.CharField(label = u'User ID', max_length=64)

View File

@@ -326,6 +326,8 @@ def user_lookup(request):
uid = RedditAccount.objects.filter(username__icontains=form.cleaned_data['username']).values('user')
for u in uid: uids.append(u['user'])
users = User.objects.filter(id__in=uids)
elif form.cleaned_data['type'] == '4':
users = User.objects.filter(email__icontains=form.cleaned_data['username'])
else:
request.user.message_set.create(message="Error parsing form, Type: %s, Value: %s" % (form.cleaned_data['type'], form.cleaned_data['username']))
return HttpResponseRedirect(reverse('sso.views.user_lookup'))