Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16837 -- Improved error message for admin login.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16872 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0781ed8ec8dab4f4658787c9dc1ca8499ccc1a18 1 parent 5a01324
Paul McMillan authored September 22, 2011
4  django/contrib/admin/forms.py
@@ -6,8 +6,8 @@
6 6
 
7 7
 from django.utils.translation import ugettext_lazy, ugettext as _
8 8
 
9  
-ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. "
10  
-                              "Note that both fields are case-sensitive.")
  9
+ERROR_MESSAGE = ugettext_lazy("Please enter the correct username and password "
  10
+        "for a staff account. Note that both fields are case-sensitive.")
11 11
 
12 12
 class AdminAuthenticationForm(AuthenticationForm):
13 13
     """
15  tests/regressiontests/admin_views/tests.py
@@ -40,6 +40,9 @@
40 40
     RowLevelChangePermissionModel, Paper, CoverLetter, Story, OtherStory,
41 41
     ComplexSortedPerson, Parent, Child)
42 42
 
  43
+ERROR_MESSAGE = "Please enter the correct username and password \
  44
+for a staff account. Note that both fields are case-sensitive."
  45
+
43 46
 
44 47
 class AdminViewBasicTest(TestCase):
45 48
     fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
@@ -761,12 +764,12 @@ def testLogin(self):
761 764
         self.assertContains(login, "Your e-mail address is not your username")
762 765
         # only correct passwords get a username hint
763 766
         login = self.client.post('/test_admin/admin/', self.super_email_bad_login)
764  
-        self.assertContains(login, "Please enter a correct username and password.")
  767
+        self.assertContains(login, ERROR_MESSAGE)
765 768
         new_user = User(username='jondoe', password='secret', email='super@example.com')
766 769
         new_user.save()
767 770
         # check to ensure if there are multiple e-mail addresses a user doesn't get a 500
768 771
         login = self.client.post('/test_admin/admin/', self.super_email_login)
769  
-        self.assertContains(login, "Please enter a correct username and password.")
  772
+        self.assertContains(login, ERROR_MESSAGE)
770 773
 
771 774
         # Add User
772 775
         request = self.client.get('/test_admin/admin/')
@@ -797,7 +800,7 @@ def testLogin(self):
797 800
         self.assertEqual(request.status_code, 200)
798 801
         login = self.client.post('/test_admin/admin/', self.joepublic_login)
799 802
         self.assertEqual(login.status_code, 200)
800  
-        self.assertContains(login, "Please enter a correct username and password.")
  803
+        self.assertContains(login, ERROR_MESSAGE)
801 804
 
802 805
         # Requests without username should not return 500 errors.
803 806
         request = self.client.get('/test_admin/admin/')
@@ -1360,12 +1363,12 @@ def test_staff_member_required_decorator_works_as_per_admin_login(self):
1360 1363
         self.assertContains(login, "Your e-mail address is not your username")
1361 1364
         # only correct passwords get a username hint
1362 1365
         login = self.client.post('/test_admin/admin/secure-view/', self.super_email_bad_login)
1363  
-        self.assertContains(login, "Please enter a correct username and password.")
  1366
+        self.assertContains(login, ERROR_MESSAGE)
1364 1367
         new_user = User(username='jondoe', password='secret', email='super@example.com')
1365 1368
         new_user.save()
1366 1369
         # check to ensure if there are multiple e-mail addresses a user doesn't get a 500
1367 1370
         login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
1368  
-        self.assertContains(login, "Please enter a correct username and password.")
  1371
+        self.assertContains(login, ERROR_MESSAGE)
1369 1372
 
1370 1373
         # Add User
1371 1374
         request = self.client.get('/test_admin/admin/secure-view/')
@@ -1397,7 +1400,7 @@ def test_staff_member_required_decorator_works_as_per_admin_login(self):
1397 1400
         login = self.client.post('/test_admin/admin/secure-view/', self.joepublic_login)
1398 1401
         self.assertEqual(login.status_code, 200)
1399 1402
         # Login.context is a list of context dicts we just need to check the first one.
1400  
-        self.assertContains(login, "Please enter a correct username and password.")
  1403
+        self.assertContains(login, ERROR_MESSAGE)
1401 1404
 
1402 1405
         # 8509 - if a normal user is already logged in, it is possible
1403 1406
         # to change user into the superuser without error

0 notes on commit 0781ed8

Please sign in to comment.
Something went wrong with that request. Please try again.