diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-04-17 01:49:22 +0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-05-31 12:48:51 -0400 |
| commit | 23e1b59cf2ad6a75637dd0273973e657e48e317e (patch) | |
| tree | db4551430adc5e599b04e9f41dc922a98a23d4a2 /tests | |
| parent | f10e9af22759cc287a967bba02c75d2834761f1e (diff) | |
Fixed #18681 -- BaseModelAdmin.get_form and InlineModelAdmin.get_formset no longer bypass get_fieldsets
Thanks msopacua for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeladmin/tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index f89f1c20ec..73e88024cd 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -64,6 +64,30 @@ class ModelAdminTests(TestCase): self.assertEqual(ma.get_fieldsets(request, self.band), [(None, {'fields': ['name', 'bio', 'sign_date']})]) + def test_get_fieldsets(self): + # Test that get_fieldsets is called when figuring out form fields. + # Refs #18681. + + class BandAdmin(ModelAdmin): + def get_fieldsets(self, request, obj=None): + return [(None, {'fields': ['name', 'bio']})] + + ma = BandAdmin(Band, self.site) + form = ma.get_form(None) + self.assertEqual(form._meta.fields, ['name', 'bio']) + + class InlineBandAdmin(TabularInline): + model = Concert + fk_name = 'main_band' + can_delete = False + + def get_fieldsets(self, request, obj=None): + return [(None, {'fields': ['day', 'transport']})] + + ma = InlineBandAdmin(Band, self.site) + form = ma.get_formset(None).form + self.assertEqual(form._meta.fields, ['day', 'transport']) + def test_field_arguments(self): # If we specify the fields argument, fieldsets_add and fielsets_change should # just stick the fields into a formsets structure and return it. |
