Ticket #12778: django-bug-12778.diff
File django-bug-12778.diff, 4.1 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
58 58 59 59 class BaseModelAdmin(object): 60 60 """Functionality common to both ModelAdmin and InlineAdmin.""" 61 __metaclass__ = forms.MediaDefiningClass 61 62 62 63 raw_id_fields = () 63 64 fields = None … … 186 187 187 188 class ModelAdmin(BaseModelAdmin): 188 189 "Encapsulates all admin options and functionality for a given model." 189 __metaclass__ = forms.MediaDefiningClass190 190 191 191 list_display = ('__str__',) 192 192 list_display_links = () -
tests/regressiontests/admin_inlines/tests.py
2 2 3 3 # local test models 4 4 from models import Holder, Inner, InnerInline 5 from models import Holder2, Inner2, Holder3, Inner3 5 6 6 7 class TestInline(TestCase): 7 8 fixtures = ['admin-views-users.xml'] … … 28 29 actual = inner_formset.can_delete 29 30 self.assertEqual(expected, actual, 'can_delete must be equal') 30 31 32 class TestInlineMedia(TestCase): 33 fixtures = ['admin-views-users.xml'] 34 35 def setUp(self): 36 37 result = self.client.login(username='super', password='secret') 38 self.failUnlessEqual(result, True) 39 40 def tearDown(self): 41 self.client.logout() 42 43 def test_inline_media_only_base(self): 44 holder = Holder(dummy=13) 45 holder.save() 46 Inner(dummy=42, holder=holder).save() 47 change_url = '/test_admin/admin/admin_inlines/holder/%i/' % holder.id 48 response = self.client.get(change_url) 49 self.assertContains(response, 'my_awesome_admin_scripts.js') 50 51 def test_inline_media_only_inline(self): 52 holder = Holder3(dummy=13) 53 holder.save() 54 Inner3(dummy=42, holder=holder).save() 55 change_url = '/test_admin/admin/admin_inlines/holder3/%i/' % holder.id 56 response = self.client.get(change_url) 57 self.assertContains(response, 'my_awesome_inline_scripts.js') 58 59 def test_all_inline_media(self): 60 holder = Holder2(dummy=13) 61 holder.save() 62 Inner2(dummy=42, holder=holder).save() 63 change_url = '/test_admin/admin/admin_inlines/holder2/%i/' % holder.id 64 response = self.client.get(change_url) 65 self.assertContains(response, 'my_awesome_admin_scripts.js') 66 self.assertContains(response, 'my_awesome_inline_scripts.js') 67 No newline at end of file -
tests/regressiontests/admin_inlines/models.py
45 45 can_delete = False 46 46 47 47 48 # Test bug #12561 49 admin.site.register(Holder, inlines=[InnerInline])48 class Holder2(models.Model): 49 dummy = models.IntegerField() 50 50 51 52 class Inner2(models.Model): 53 dummy = models.IntegerField() 54 holder = models.ForeignKey(Holder2) 55 56 class HolderAdmin(admin.ModelAdmin): 57 58 class Media: 59 js = ('my_awesome_admin_scripts.js',) 60 61 class InnerInline2(admin.StackedInline): 62 model = Inner2 63 64 class Media: 65 js = ('my_awesome_inline_scripts.js',) 66 67 class Holder3(models.Model): 68 dummy = models.IntegerField() 69 70 71 class Inner3(models.Model): 72 dummy = models.IntegerField() 73 holder = models.ForeignKey(Holder3) 74 75 class InnerInline3(admin.StackedInline): 76 model = Inner3 77 78 class Media: 79 js = ('my_awesome_inline_scripts.js',) 80 81 # Test bug #12561 and #12778 82 # only ModelAdmin media 83 admin.site.register(Holder, HolderAdmin, inlines=[InnerInline]) 84 # ModelAdmin and Inline media 85 admin.site.register(Holder2, HolderAdmin, inlines=[InnerInline2]) 86 # only Inline media 87 admin.site.register(Holder3, inlines=[InnerInline3]) 88 51 89 __test__ = {'API_TESTS': """ 52 90 53 91 # Regression test for #9362