summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2008-05-16 22:53:39 +0000
committerLuke Plant <L.Plant.98@cantab.net>2008-05-16 22:53:39 +0000
commit6f76b9f58d3b34d71f31d088dc629d3337aef24e (patch)
tree723089d42b0eeec9c60b0a3f29397e37d136f022
parent7e4718f8d5d511efdbb17e99f37e97f5b91bfd6c (diff)
Simplified control flow for change made in r7535
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7536 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/views/decorators.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py
index 3039daadb1..c27b2e7427 100644
--- a/django/contrib/admin/views/decorators.py
+++ b/django/contrib/admin/views/decorators.py
@@ -84,18 +84,13 @@ def staff_member_required(view_func):
message = ERROR_MESSAGE
if '@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
- try:
- users = list(User.objects.filter(email=username))
- if len(users) == 1:
- user = users[0]
- else:
- # Either we cannot find the user, or if more than 1
- # we cannot guess which user is the correct one.
- raise User.DoesNotExist()
- except User.DoesNotExist:
- message = _("Usernames cannot contain the '@' character.")
+ users = list(User.objects.filter(email=username))
+ if len(users) == 1:
+ message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username
else:
- message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username
+ # Either we cannot find the user, or if more than 1
+ # we cannot guess which user is the correct one.
+ message = _("Usernames cannot contain the '@' character.")
return _display_login_form(request, message)
# The user data is correct; log in the user in and continue.