Ticket #12561: patch-12561.diff
File patch-12561.diff, 2.8 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
1227 1227 "formfield_callback": curry(self.formfield_for_dbfield, request=request), 1228 1228 "extra": self.extra, 1229 1229 "max_num": self.max_num, 1230 "can_delete": self.can_delete, 1231 "can_order": self.can_order, 1230 1232 } 1231 1233 defaults.update(kwargs) 1232 1234 return inlineformset_factory(self.parent_model, self.model, **defaults) -
tests/regressiontests/admin_inlines/tests.py
1 # coding: utf-8 2 3 from django.test import TestCase 4 from django.contrib import admin 5 6 # local test models 7 from models import Holder, Inner 8 9 class TestInline(TestCase): 10 fixtures = ['admin-views-users.xml'] 11 12 def setUp(self): 13 self.holder = Holder(dummy=13) 14 self.holder.save() 15 Inner(dummy=42, holder=self.holder).save() 16 17 result = self.client.login(username='super', password='secret') 18 self.failUnlessEqual(result, True) 19 20 def tearDown(self): 21 Inner.objects.all().delete() 22 Holder.objects.all().delete() 23 self.client.logout() 24 25 def test_can_delete(self): 26 """ 27 can_delete should be passed to inlineformset factory. 28 """ 29 url = '/test_admin/admin/admin_inlines/holder/%i/' % self.holder.id 30 response = self.client.get(url) 31 with file('test.html', 'w') as f: 32 f.write(str(response)) 33 self.assertNotContains(response, text='name="neverdeletemodel_set-0-DELETE"') -
tests/regressiontests/admin_inlines/models.py
3 3 4 4 """ 5 5 from django.db import models 6 from django.contrib import admin 6 7 from django.contrib.contenttypes.models import ContentType 7 8 from django.contrib.contenttypes import generic 8 9 … … 29 30 def __unicode__(self): 30 31 return u'I am %s, a child of %s' % (self.name, self.parent) 31 32 33 34 class Holder(models.Model): 35 dummy = models.IntegerField() 36 37 38 class Inner(models.Model): 39 dummy = models.IntegerField() 40 holder = models.ForeignKey(Holder) 41 42 43 class InnerInline(admin.StackedInline): 44 model = Inner 45 can_delete = False 46 can_order = True 47 48 49 # Test bug #12561 50 admin.site.register(Holder, inlines=[InnerInline]) 51 32 52 __test__ = {'API_TESTS': """ 33 53 34 54 # Regression test for #9362