Changed "date" column to "start_date"--Oracle won't name columns with reserved keywords.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9764 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
547649f962
commit
b120c74032
|
@ -29,24 +29,24 @@ class Album(models.Model):
|
||||||
|
|
||||||
class HiddenInventoryManager(models.Manager):
|
class HiddenInventoryManager(models.Manager):
|
||||||
def get_query_set(self):
|
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):
|
class Inventory(models.Model):
|
||||||
barcode = models.PositiveIntegerField(unique=True)
|
barcode = models.PositiveIntegerField(unique=True)
|
||||||
parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
|
parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
|
||||||
name = models.CharField(blank=False, max_length=20)
|
name = models.CharField(blank=False, max_length=20)
|
||||||
hidden = models.BooleanField(default=False)
|
hidden = models.BooleanField(default=False)
|
||||||
|
|
||||||
# see #9258
|
# see #9258
|
||||||
default_manager = models.Manager()
|
default_manager = models.Manager()
|
||||||
objects = HiddenInventoryManager()
|
objects = HiddenInventoryManager()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Event(models.Model):
|
class Event(models.Model):
|
||||||
band = models.ForeignKey(Band)
|
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)
|
start_time = models.TimeField(blank=True, null=True)
|
||||||
description = models.TextField(blank=True)
|
description = models.TextField(blank=True)
|
||||||
link = models.URLField(blank=True)
|
link = models.URLField(blank=True)
|
||||||
|
@ -56,7 +56,7 @@ class Car(models.Model):
|
||||||
owner = models.ForeignKey(User)
|
owner = models.ForeignKey(User)
|
||||||
make = models.CharField(max_length=30)
|
make = models.CharField(max_length=30)
|
||||||
model = models.CharField(max_length=30)
|
model = models.CharField(max_length=30)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"%s %s" % (self.make, self.model)
|
return u"%s %s" % (self.make, self.model)
|
||||||
|
|
||||||
|
@ -137,9 +137,9 @@ True
|
||||||
<input type="text" name="test" value="86" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Apple</strong>
|
<input type="text" name="test" value="86" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Apple</strong>
|
||||||
|
|
||||||
# see #9258
|
# 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)
|
>>> 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={})
|
||||||
<input type="text" name="test" value="93" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Hidden</strong>
|
<input type="text" name="test" value="93" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Hidden</strong>
|
||||||
""" % {
|
""" % {
|
||||||
'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX,
|
'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX,
|
||||||
|
|
|
@ -19,89 +19,89 @@ class AdminFormfieldForDBFieldTests(TestCase):
|
||||||
class MyModelAdmin(admin.ModelAdmin): pass
|
class MyModelAdmin(admin.ModelAdmin): pass
|
||||||
for k in admin_overrides:
|
for k in admin_overrides:
|
||||||
setattr(MyModelAdmin, k, admin_overrides[k])
|
setattr(MyModelAdmin, k, admin_overrides[k])
|
||||||
|
|
||||||
# Construct the admin, and ask it for a formfield
|
# Construct the admin, and ask it for a formfield
|
||||||
ma = MyModelAdmin(model, admin.site)
|
ma = MyModelAdmin(model, admin.site)
|
||||||
ff = ma.formfield_for_dbfield(model._meta.get_field(fieldname), request=None)
|
ff = ma.formfield_for_dbfield(model._meta.get_field(fieldname), request=None)
|
||||||
|
|
||||||
# "unwrap" the widget wrapper, if needed
|
# "unwrap" the widget wrapper, if needed
|
||||||
if isinstance(ff.widget, widgets.RelatedFieldWidgetWrapper):
|
if isinstance(ff.widget, widgets.RelatedFieldWidgetWrapper):
|
||||||
widget = ff.widget.widget
|
widget = ff.widget.widget
|
||||||
else:
|
else:
|
||||||
widget = ff.widget
|
widget = ff.widget
|
||||||
|
|
||||||
# Check that we got a field of the right type
|
# Check that we got a field of the right type
|
||||||
self.assert_(
|
self.assert_(
|
||||||
isinstance(widget, widgetclass),
|
isinstance(widget, widgetclass),
|
||||||
"Wrong widget for %s.%s: expected %s, got %s" % \
|
"Wrong widget for %s.%s: expected %s, got %s" % \
|
||||||
(model.__class__.__name__, fieldname, widgetclass, type(widget))
|
(model.__class__.__name__, fieldname, widgetclass, type(widget))
|
||||||
)
|
)
|
||||||
|
|
||||||
# Return the formfield so that other tests can continue
|
# Return the formfield so that other tests can continue
|
||||||
return ff
|
return ff
|
||||||
|
|
||||||
def testDateField(self):
|
def testDateField(self):
|
||||||
self.assertFormfield(models.Event, 'date', widgets.AdminDateWidget)
|
self.assertFormfield(models.Event, 'start_date', widgets.AdminDateWidget)
|
||||||
|
|
||||||
def testDateTimeField(self):
|
def testDateTimeField(self):
|
||||||
self.assertFormfield(models.Member, 'birthdate', widgets.AdminSplitDateTime)
|
self.assertFormfield(models.Member, 'birthdate', widgets.AdminSplitDateTime)
|
||||||
|
|
||||||
def testTimeField(self):
|
def testTimeField(self):
|
||||||
self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget)
|
self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget)
|
||||||
|
|
||||||
def testTextField(self):
|
def testTextField(self):
|
||||||
self.assertFormfield(models.Event, 'description', widgets.AdminTextareaWidget)
|
self.assertFormfield(models.Event, 'description', widgets.AdminTextareaWidget)
|
||||||
|
|
||||||
def testURLField(self):
|
def testURLField(self):
|
||||||
self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget)
|
self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget)
|
||||||
|
|
||||||
def testIntegerField(self):
|
def testIntegerField(self):
|
||||||
self.assertFormfield(models.Event, 'min_age', widgets.AdminIntegerFieldWidget)
|
self.assertFormfield(models.Event, 'min_age', widgets.AdminIntegerFieldWidget)
|
||||||
|
|
||||||
def testCharField(self):
|
def testCharField(self):
|
||||||
self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget)
|
self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget)
|
||||||
|
|
||||||
def testFileField(self):
|
def testFileField(self):
|
||||||
self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget)
|
self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget)
|
||||||
|
|
||||||
def testForeignKey(self):
|
def testForeignKey(self):
|
||||||
self.assertFormfield(models.Event, 'band', forms.Select)
|
self.assertFormfield(models.Event, 'band', forms.Select)
|
||||||
|
|
||||||
def testRawIDForeignKey(self):
|
def testRawIDForeignKey(self):
|
||||||
self.assertFormfield(models.Event, 'band', widgets.ForeignKeyRawIdWidget,
|
self.assertFormfield(models.Event, 'band', widgets.ForeignKeyRawIdWidget,
|
||||||
raw_id_fields=['band'])
|
raw_id_fields=['band'])
|
||||||
|
|
||||||
def testRadioFieldsForeignKey(self):
|
def testRadioFieldsForeignKey(self):
|
||||||
ff = self.assertFormfield(models.Event, 'band', widgets.AdminRadioSelect,
|
ff = self.assertFormfield(models.Event, 'band', widgets.AdminRadioSelect,
|
||||||
radio_fields={'band':admin.VERTICAL})
|
radio_fields={'band':admin.VERTICAL})
|
||||||
self.assertEqual(ff.empty_label, None)
|
self.assertEqual(ff.empty_label, None)
|
||||||
|
|
||||||
def testManyToMany(self):
|
def testManyToMany(self):
|
||||||
self.assertFormfield(models.Band, 'members', forms.SelectMultiple)
|
self.assertFormfield(models.Band, 'members', forms.SelectMultiple)
|
||||||
|
|
||||||
def testRawIDManyTOMany(self):
|
def testRawIDManyTOMany(self):
|
||||||
self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget,
|
self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget,
|
||||||
raw_id_fields=['members'])
|
raw_id_fields=['members'])
|
||||||
|
|
||||||
def testFilteredManyToMany(self):
|
def testFilteredManyToMany(self):
|
||||||
self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple,
|
self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple,
|
||||||
filter_vertical=['members'])
|
filter_vertical=['members'])
|
||||||
|
|
||||||
def testFormfieldOverrides(self):
|
def testFormfieldOverrides(self):
|
||||||
self.assertFormfield(models.Event, 'date', forms.TextInput,
|
self.assertFormfield(models.Event, 'start_date', forms.TextInput,
|
||||||
formfield_overrides={'widget': forms.TextInput})
|
formfield_overrides={'widget': forms.TextInput})
|
||||||
|
|
||||||
def testFieldWithChoices(self):
|
def testFieldWithChoices(self):
|
||||||
self.assertFormfield(models.Member, 'gender', forms.Select)
|
self.assertFormfield(models.Member, 'gender', forms.Select)
|
||||||
|
|
||||||
def testChoicesWithRadioFields(self):
|
def testChoicesWithRadioFields(self):
|
||||||
self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,
|
self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,
|
||||||
radio_fields={'gender':admin.VERTICAL})
|
radio_fields={'gender':admin.VERTICAL})
|
||||||
|
|
||||||
|
|
||||||
class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
|
class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
|
||||||
fixtures = ["admin-widgets-users.xml"]
|
fixtures = ["admin-widgets-users.xml"]
|
||||||
|
|
||||||
def testFilterChoicesByRequestUser(self):
|
def testFilterChoicesByRequestUser(self):
|
||||||
"""
|
"""
|
||||||
Ensure the user can only see their own cars in the foreign key dropdown.
|
Ensure the user can only see their own cars in the foreign key dropdown.
|
||||||
|
|
Loading…
Reference in New Issue