reporead: ignore nicknames in name matching code

This commit is contained in:
Dan McGee 2010-10-04 13:29:01 -05:00
parent ed49122429
commit 5e509529f0

View File

@ -137,6 +137,10 @@ def user_name():
# one of the two name fields. # one of the two name fields.
name_q = Q() name_q = Q()
for token in name.split(): for token in name.split():
# ignore quoted parts; e.g. nicknames in strings
if re.match(r'^[\'"].*[\'"]$', token):
print "token match:", token
continue
name_q &= (Q(first_name__icontains=token) | name_q &= (Q(first_name__icontains=token) |
Q(last_name__icontains=token)) Q(last_name__icontains=token))
return User.objects.get(name_q) return User.objects.get(name_q)