diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-08 12:23:23 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-08 12:23:23 +0000 |
| commit | 27e7fcbab015452cb4201f32eb2682bd8dc23feb (patch) | |
| tree | f5fb8b300a2f8b0058e7d0702ec5e69be799c3db /tests | |
| parent | 09a820550b0d4bff9fc4fd641a1d6707b3cc0c85 (diff) | |
[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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/admin_views/models.py | 5 | ||||
| -rw-r--r-- | tests/regressiontests/admin_views/tests.py | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py index b840c0a4b5..60d8d06942 100644 --- a/tests/regressiontests/admin_views/models.py +++ b/tests/regressiontests/admin_views/models.py @@ -629,6 +629,10 @@ class WorkHourAdmin(admin.ModelAdmin): list_display = ('datum', 'employee') list_filter = ('employee',) +class Reservation(models.Model): + start_date = models.DateTimeField() + price = models.IntegerField() + admin.site.register(Article, ArticleAdmin) admin.site.register(CustomArticle, CustomArticleAdmin) admin.site.register(Section, save_as=True, inlines=[ArticleInline]) @@ -664,6 +668,7 @@ admin.site.register(PlotDetails) admin.site.register(CyclicOne) admin.site.register(CyclicTwo) admin.site.register(WorkHour, WorkHourAdmin) +admin.site.register(Reservation) # We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2. # That way we cover all four cases: diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 97f9061a23..384959c500 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -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'] |
