diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-05-03 13:38:36 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-05-03 13:38:36 +0000 |
| commit | 80a54dd23bfda4bb297f9b13f2a54c1f10664cf5 (patch) | |
| tree | f2d17d7382dbd25db6ffbfe054ff895271940d89 /tests | |
| parent | 2c24bba934d26ee79f41961859c70935bfc4cd83 (diff) | |
Fixed #9362 -- Prevented inline forms from overwriting the content_type_id attribute on objets being inlined. Thanks to carljm for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10667 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/admin_inlines/__init__.py | 0 | ||||
| -rw-r--r-- | tests/regressiontests/admin_inlines/models.py | 51 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_inlines/__init__.py b/tests/regressiontests/admin_inlines/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/regressiontests/admin_inlines/__init__.py diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py new file mode 100644 index 0000000000..1893bfc508 --- /dev/null +++ b/tests/regressiontests/admin_inlines/models.py @@ -0,0 +1,51 @@ +""" +Testing of admin inline formsets. + +""" +from django.db import models +from django.contrib.contenttypes.models import ContentType +from django.contrib.contenttypes import generic + +class Parent(models.Model): + name = models.CharField(max_length=50) + + def __unicode__(self): + return self.name + +class Teacher(models.Model): + name = models.CharField(max_length=50) + + def __unicode__(self): + return self.name + +class Child(models.Model): + name = models.CharField(max_length=50) + teacher = models.ForeignKey(Teacher) + + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + parent = generic.GenericForeignKey() + + def __unicode__(self): + return u'I am %s, a child of %s' % (self.name, self.parent) + +__test__ = {'API_TESTS': """ + +# Regression test for #9362 + +>>> sally = Teacher.objects.create(name='Sally') +>>> john = Parent.objects.create(name='John') +>>> joe = Child.objects.create(name='Joe', teacher=sally, parent=john) + +The problem depends only on InlineAdminForm and its "original" argument, so +we can safely set the other arguments to None/{}. We just need to check that +the content_type argument of Child isn't altered by the internals of the +inline form. + +>>> from django.contrib.admin.helpers import InlineAdminForm +>>> iaf = InlineAdminForm(None, None, {}, {}, joe) +>>> iaf.original +<Child: I am Joe, a child of John> + +""" +}
\ No newline at end of file |
