mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.2.X] Fixed #10573 -- Corrected autofocus problem in admin when the first widget displayed is a multiwidget. Thanks to rduffield for the report, and to Ramiro and Julien Phalip for the patch.
Backport of r15452 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15456 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -376,6 +376,29 @@ class AdminViewBasicTest(TestCase):
|
||||
except SuspiciousOperation:
|
||||
self.fail("Filters should be allowed if they are defined on a ForeignKey pointing to this model")
|
||||
|
||||
class AdminJavaScriptTest(AdminViewBasicTest):
|
||||
def testSingleWidgetFirsFieldFocus(self):
|
||||
"""
|
||||
JavaScript-assisted auto-focus on first field.
|
||||
"""
|
||||
response = self.client.get('/test_admin/%s/admin_views/picture/add/' % self.urlbit)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<script type="text/javascript">document.getElementById("id_name").focus();</script>'
|
||||
)
|
||||
|
||||
def testMultiWidgetFirsFieldFocus(self):
|
||||
"""
|
||||
JavaScript-assisted auto-focus should work if a model/ModelAdmin setup
|
||||
is such that the first form field has a MultiWidget.
|
||||
"""
|
||||
response = self.client.get('/test_admin/%s/admin_views/reservation/add/' % self.urlbit)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<script type="text/javascript">document.getElementById("id_start_date_0").focus();</script>'
|
||||
)
|
||||
|
||||
|
||||
class SaveAsTests(TestCase):
|
||||
fixtures = ['admin-views-users.xml','admin-views-person.xml']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user