Ticket #19524: 19524.testcase.diff

File 19524.testcase.diff, 3.6 KB (added by Aymeric Augustin, 12 years ago)
  • tests/regressiontests/admin_inlines/admin.py

    diff --git a/tests/regressiontests/admin_inlines/admin.py b/tests/regressiontests/admin_inlines/admin.py
    index cf51fa4..536c3ec 100644
    a b class ChildModel1Inline(admin.TabularInline):  
    124124class ChildModel2Inline(admin.StackedInline):
    125125    model = ChildModel2
    126126
     127# admin for #19524
     128class SightingInline(admin.TabularInline):
     129    model = Sighting
    127130
    128131site.register(TitleCollection, inlines=[TitleInline])
    129132# Test bug #12561 and #12778
    site.register(Holder4, Holder4Admin)  
    141144site.register(Author, AuthorAdmin)
    142145site.register(CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline])
    143146site.register(ProfileCollection, inlines=[ProfileInline])
    144 site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline])
    145  No newline at end of file
     147site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline])
     148site.register(ExtraTerrestrial, inlines=[SightingInline])
  • tests/regressiontests/admin_inlines/models.py

    diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py
    index b004d5f..147873a 100644
    a b class Inner4Tabular(models.Model):  
    9090    dummy = models.IntegerField(help_text="Awesome tabular help text is awesome.")
    9191    holder = models.ForeignKey(Holder4)
    9292
    93 
    9493# Models for #12749
    9594
    9695class Person(models.Model):
    class Chapter(models.Model):  
    133132
    134133
    135134# Models for #16838
     135
    136136class CapoFamiglia(models.Model):
    137137    name = models.CharField(max_length=100)
    138138
    class ChildModel2(models.Model):  
    170170    def get_absolute_url(self):
    171171        return '/child_model2/'
    172172
     173# Models for #19524
     174
     175class LifeForm(models.Model):
     176    pass
     177
     178class ExtraTerrestrial(LifeForm):
     179    name = models.CharField(max_length=100)
     180
     181class Sighting(models.Model):
     182    et = models.ForeignKey(ExtraTerrestrial)
     183    place = models.CharField(max_length=100)
    173184
    174185# Other models
    175186
  • tests/regressiontests/admin_inlines/tests.py

    diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py
    index 3c86801..54283bf 100644
    a b from .admin import InnerInline, TitleInline, site  
    1212from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
    1313    OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book, Profile,
    1414    ProfileCollection, ParentModelWithCustomPk, ChildModel1, ChildModel2,
    15     Title)
     15    Sighting, Title)
    1616
    1717
    1818@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
    class TestInline(TestCase):  
    172172        self.assertContains(response, child1_shortcut)
    173173        self.assertContains(response, child2_shortcut)
    174174
     175    def test_create_inlines_on_inherited_model(self):
     176        """
     177        Ensure that an object can be created with inlines when it inherits
     178        another class. Bug #19524.
     179        """
     180        data = {
     181            'name': 'Martian',
     182            'sighting_set-TOTAL_FORMS': 1,
     183            'sighting_set-INITIAL_FORMS': 0,
     184            'sighting_set-MAX_NUM_FORMS': 0,
     185            'sighting_set-0-place': 'Zone 51',
     186            '_save': 'Save',
     187        }
     188        response = self.client.post('/admin/admin_inlines/extraterrestrial/add/', data)
     189        self.assertEqual(response.status_code, 302)
     190        self.assertEqual(Sighting.objects.filter(et__name='Martian').count(), 1)
     191
    175192
    176193@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
    177194class TestInlineMedia(TestCase):
Back to Top