diff --git a/tests/regressiontests/admin_widgets/models.py b/tests/regressiontests/admin_widgets/models.py
index 345d73b0ea..1ba759b2d3 100644
--- a/tests/regressiontests/admin_widgets/models.py
+++ b/tests/regressiontests/admin_widgets/models.py
@@ -29,24 +29,24 @@ class Album(models.Model):
class HiddenInventoryManager(models.Manager):
def get_query_set(self):
- return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
+ return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
class Inventory(models.Model):
barcode = models.PositiveIntegerField(unique=True)
parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
name = models.CharField(blank=False, max_length=20)
hidden = models.BooleanField(default=False)
-
+
# see #9258
default_manager = models.Manager()
objects = HiddenInventoryManager()
def __unicode__(self):
return self.name
-
+
class Event(models.Model):
band = models.ForeignKey(Band)
- date = models.DateField(blank=True, null=True)
+ start_date = models.DateField(blank=True, null=True)
start_time = models.TimeField(blank=True, null=True)
description = models.TextField(blank=True)
link = models.URLField(blank=True)
@@ -56,7 +56,7 @@ class Car(models.Model):
owner = models.ForeignKey(User)
make = models.CharField(max_length=30)
model = models.CharField(max_length=30)
-
+
def __unicode__(self):
return u"%s %s" % (self.make, self.model)
@@ -137,9 +137,9 @@ True
Apple
# see #9258
->>> hidden = Inventory.objects.create(barcode=93, name='Hidden', hidden=True)
+>>> hidden = Inventory.objects.create(barcode=93, name='Hidden', hidden=True)
>>> child_of_hidden = Inventory.objects.create(barcode=94, name='Child of hidden', parent=hidden)
->>> print w.render('test', child_of_hidden.parent_id, attrs={})
+>>> print w.render('test', child_of_hidden.parent_id, attrs={})
Hidden
""" % {
'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX,
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 2794b3fb80..4dc2930e3b 100644
--- a/tests/regressiontests/admin_widgets/tests.py
+++ b/tests/regressiontests/admin_widgets/tests.py
@@ -19,89 +19,89 @@ class AdminFormfieldForDBFieldTests(TestCase):
class MyModelAdmin(admin.ModelAdmin): pass
for k in admin_overrides:
setattr(MyModelAdmin, k, admin_overrides[k])
-
+
# Construct the admin, and ask it for a formfield
ma = MyModelAdmin(model, admin.site)
ff = ma.formfield_for_dbfield(model._meta.get_field(fieldname), request=None)
-
+
# "unwrap" the widget wrapper, if needed
if isinstance(ff.widget, widgets.RelatedFieldWidgetWrapper):
widget = ff.widget.widget
else:
widget = ff.widget
-
+
# Check that we got a field of the right type
self.assert_(
- isinstance(widget, widgetclass),
+ isinstance(widget, widgetclass),
"Wrong widget for %s.%s: expected %s, got %s" % \
(model.__class__.__name__, fieldname, widgetclass, type(widget))
)
-
+
# Return the formfield so that other tests can continue
return ff
-
+
def testDateField(self):
- self.assertFormfield(models.Event, 'date', widgets.AdminDateWidget)
-
+ self.assertFormfield(models.Event, 'start_date', widgets.AdminDateWidget)
+
def testDateTimeField(self):
self.assertFormfield(models.Member, 'birthdate', widgets.AdminSplitDateTime)
-
+
def testTimeField(self):
self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget)
def testTextField(self):
self.assertFormfield(models.Event, 'description', widgets.AdminTextareaWidget)
-
+
def testURLField(self):
self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget)
def testIntegerField(self):
self.assertFormfield(models.Event, 'min_age', widgets.AdminIntegerFieldWidget)
-
+
def testCharField(self):
self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget)
-
+
def testFileField(self):
self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget)
-
+
def testForeignKey(self):
self.assertFormfield(models.Event, 'band', forms.Select)
-
+
def testRawIDForeignKey(self):
self.assertFormfield(models.Event, 'band', widgets.ForeignKeyRawIdWidget,
raw_id_fields=['band'])
-
+
def testRadioFieldsForeignKey(self):
- ff = self.assertFormfield(models.Event, 'band', widgets.AdminRadioSelect,
+ ff = self.assertFormfield(models.Event, 'band', widgets.AdminRadioSelect,
radio_fields={'band':admin.VERTICAL})
self.assertEqual(ff.empty_label, None)
-
+
def testManyToMany(self):
self.assertFormfield(models.Band, 'members', forms.SelectMultiple)
-
+
def testRawIDManyTOMany(self):
self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget,
raw_id_fields=['members'])
-
+
def testFilteredManyToMany(self):
self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple,
filter_vertical=['members'])
-
+
def testFormfieldOverrides(self):
- self.assertFormfield(models.Event, 'date', forms.TextInput,
+ self.assertFormfield(models.Event, 'start_date', forms.TextInput,
formfield_overrides={'widget': forms.TextInput})
-
+
def testFieldWithChoices(self):
self.assertFormfield(models.Member, 'gender', forms.Select)
-
+
def testChoicesWithRadioFields(self):
- self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,
+ self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,
radio_fields={'gender':admin.VERTICAL})
class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
fixtures = ["admin-widgets-users.xml"]
-
+
def testFilterChoicesByRequestUser(self):
"""
Ensure the user can only see their own cars in the foreign key dropdown.