Ticket #11061: adminsite.patch
File adminsite.patch, 1.9 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/sites.py
293 293 user = authenticate(username=username, password=password) 294 294 if user is None: 295 295 message = ERROR_MESSAGE 296 if u '@' in username:296 if username is not None and u'@' in username: 297 297 # Mistakenly entered e-mail address instead of username? Look it up. 298 298 try: 299 299 user = User.objects.get(email=username) -
tests/regressiontests/admin_views/tests.py
347 347 LOGIN_FORM_KEY: 1, 348 348 'username': 'joepublic', 349 349 'password': 'secret'} 350 self.no_username_login = { 351 LOGIN_FORM_KEY: 1, 352 'password': 'secret'} 350 353 351 354 def testLogin(self): 352 355 """ … … 410 413 # Login.context is a list of context dicts we just need to check the first one. 411 414 self.assert_(login.context[0].get('error_message')) 412 415 416 # Requests without username should not fail 417 request = self.client.get('/test_admin/admin/') 418 self.failUnlessEqual(request.status_code, 200) 419 login = self.client.post('/test_admin/admin/', self.no_username_login) 420 self.failUnlessEqual(login.status_code, 200) 421 # Login.context is a list of context dicts we just need to check the first one. 422 self.assert_(login.context[0].get('error_message')) 423 424 413 425 def testLoginSuccessfullyRedirectsToOriginalUrl(self): 414 426 request = self.client.get('/test_admin/admin/') 415 427 self.failUnlessEqual(request.status_code, 200)