Added the ability to search by EVE API User ID

This commit is contained in:
2011-02-01 15:55:16 +00:00
parent 2bde07cca6
commit 9e839023e8
2 changed files with 5 additions and 5 deletions

View File

@@ -91,15 +91,12 @@ class ServiceAccountResetForm(forms.Form):
class UserLookupForm(forms.Form): class UserLookupForm(forms.Form):
""" User Lookup Form """ """ User Lookup Form """
choices = [(1, "Auth Username"),
(2, "Character"),
(4, "Email Address"), ]
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(UserLookupForm, self).__init__(*args, **kwargs) super(UserLookupForm, self).__init__(*args, **kwargs)
choices = [(1, "Auth Username"), choices = [(1, "Auth Username"),
(2, "Character"), (2, "Character"),
(4, "Email Address"), ] (4, "Email Address"),
(5, "EVE API User ID"), ]
if installed('reddit'): if installed('reddit'):
choices.append((3, "Reddit ID")) choices.append((3, "Reddit ID"))

View File

@@ -195,6 +195,9 @@ def user_lookup(request):
users = User.objects.filter(id__in=uids).only('username') users = User.objects.filter(id__in=uids).only('username')
elif form.cleaned_data['type'] == '4': elif form.cleaned_data['type'] == '4':
users = User.objects.filter(email__icontains=form.cleaned_data['username']).only('username') users = User.objects.filter(email__icontains=form.cleaned_data['username']).only('username')
elif form.cleaned_data['type'] == '5':
uids = EVEAccount.objects.filter(id__icontains=form.cleaned_data['username']).values_list('user', flat=True)
users = User.objects.filter(id__in=uids).only('username')
else: else:
messages.add_message(request, messages.ERROR, "Error parsing form, Type: %s, Value: %s" % (form.cleaned_data['type'], form.cleaned_data['username'])) messages.add_message(request, messages.ERROR, "Error parsing form, Type: %s, Value: %s" % (form.cleaned_data['type'], form.cleaned_data['username']))
return redirect('sso.views.user_lookup') return redirect('sso.views.user_lookup')