Ticket #12073: 12073.diff
File 12073.diff, 3.1 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/widgets.py
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index 0d1f2a9..88b74a4 100644
a b class AdminDateWidget(forms.DateInput): 54 54 return forms.Media(js=[static("admin/js/%s" % path) for path in js]) 55 55 56 56 def __init__(self, attrs={}, format=None): 57 super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'}, format=format) 57 attr={'class': 'vDateField', 'size': '10'} 58 attr.update(attrs) 59 super(AdminDateWidget, self).__init__(attrs=attr, format=format) 58 60 59 61 class AdminTimeWidget(forms.TimeInput): 60 62 … … class AdminTimeWidget(forms.TimeInput): 64 66 return forms.Media(js=[static("admin/js/%s" % path) for path in js]) 65 67 66 68 def __init__(self, attrs={}, format=None): 67 super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'}, format=format) 69 attr={'class': 'vTimeField', 'size': '8'} 70 attr.update(attrs) 71 super(AdminTimeWidget, self).__init__(attrs=attr, format=format) 68 72 69 73 class AdminSplitDateTime(forms.SplitDateTimeWidget): 70 74 """ -
tests/regressiontests/admin_widgets/tests.py
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py index 08a1a59..751d074 100644
a b class FilteredSelectMultipleWidgetTest(DjangoTestCase): 205 205 '<select multiple="multiple" name="test" class="selectfilterstacked">\n</select><script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("id_test", "test", 1, "%(ADMIN_MEDIA_PREFIX)s"); });</script>\n' % admin_media_prefix() 206 206 ) 207 207 208 class AdminDateWidgetTest(DjangoTestCase): 209 def test_render(self): 210 w = widgets.AdminDateWidget() 211 self.assertEqual( 212 conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))), 213 '<input value="2007-12-01" type="text" class="vDateField" name="test" size="10" />', 214 ) 215 # pass attrs to widget 216 w = widgets.AdminDateWidget(attrs={'size': 20, 'class': 'myDateField'}) 217 self.assertEqual( 218 conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))), 219 '<input value="2007-12-01" type="text" class="myDateField" name="test" size="20" />', 220 ) 221 222 class AdminTimeWidgetTest(DjangoTestCase): 223 def test_render(self): 224 w = widgets.AdminTimeWidget() 225 self.assertEqual( 226 conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))), 227 '<input value="09:30:00" type="text" class="vTimeField" name="test" size="8" />', 228 ) 229 # pass attrs to widget 230 w = widgets.AdminTimeWidget(attrs={'size': 20, 'class': 'myTimeField'}) 231 self.assertEqual( 232 conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))), 233 '<input value="09:30:00" type="text" class="myTimeField" name="test" size="20" />', 234 ) 208 235 209 236 class AdminSplitDateTimeWidgetTest(DjangoTestCase): 210 237 def test_render(self):