Django

Code

Changeset 7536 for django/trunk

Show
Ignore:
Timestamp:
05/16/08 17:53:39 (6 months ago)
Author:
lukeplant
Message:

Simplified control flow for change made in r7535

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/views/decorators.py

    r7535 r7536  
    8585            if '@' in username: 
    8686                # Mistakenly entered e-mail address instead of username? Look it up. 
    87                 try: 
    88                     users = list(User.objects.filter(email=username)) 
    89                     if len(users) == 1: 
    90                         user = users[0] 
    91                     else: 
    92                         # Either we cannot find the user, or if more than 1  
    93                         # we cannot guess which user is the correct one. 
    94                         raise User.DoesNotExist()                         
    95                 except User.DoesNotExist: 
     87                users = list(User.objects.filter(email=username)) 
     88                if len(users) == 1: 
     89                    message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username 
     90                else: 
     91                    # Either we cannot find the user, or if more than 1  
     92                    # we cannot guess which user is the correct one. 
    9693                    message = _("Usernames cannot contain the '@' character.") 
    97                 else: 
    98                     message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username 
    9994            return _display_login_form(request, message) 
    10095