Ticket #6943: 6943-nfa-admin-multiple-emails.diff
File 6943-nfa-admin-multiple-emails.diff, 2.4 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/sites.py
231 231 # Mistakenly entered e-mail address instead of username? Look it up. 232 232 try: 233 233 user = User.objects.get(email=username) 234 except User.DoesNotExist:234 except (User.DoesNotExist, User.MultipleObjectsReturned): 235 235 message = _("Usernames cannot contain the '@' character.") 236 236 else: 237 237 message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username -
tests/regressiontests/admin_views/tests.py
46 46 LOGIN_FORM_KEY: 1, 47 47 'username': 'super', 48 48 'password': 'secret'} 49 self.super_email_login = {'post_data': _encode_post_data({}), 50 LOGIN_FORM_KEY: 1, 51 'username': 'super@example.com', 52 'password': 'secret'} 49 53 self.adduser_login = {'post_data': _encode_post_data({}), 50 54 LOGIN_FORM_KEY: 1, 51 55 'username': 'adduser', … … 80 84 self.assertFalse(login.context) 81 85 self.client.get('/test_admin/admin/logout/') 82 86 87 # Test if user enters e-mail address 88 request = self.client.get('/test_admin/admin/') 89 self.failUnlessEqual(request.status_code, 200) 90 login = self.client.post('/test_admin/admin/', self.super_email_login) 91 self.assertContains(login, "Your e-mail address is not your username") 92 new_user = User(username='jondoe', password='secret', email='super@example.com') 93 new_user.save() 94 # check to ensure if there are multiple e-mail addresses a user doesn't get a 500 95 login = self.client.post('/test_admin/admin/', self.super_email_login) 96 self.assertContains(login, "Usernames cannot contain the '@' character") 97 83 98 # Add User 84 99 request = self.client.get('/test_admin/admin/') 85 100 self.failUnlessEqual(request.status_code, 200)