mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #27991 -- Made obj a required argument of InlineModelAdmin.has_add_permission().
Per deprecation timeline.
This commit is contained in:
@@ -734,10 +734,6 @@ class ModelAdminPermissionTests(SimpleTestCase):
|
||||
def has_perm(self, perm):
|
||||
return perm == 'modeladmin.add_band'
|
||||
|
||||
class MockAddUserWithInline(MockUser):
|
||||
def has_perm(self, perm):
|
||||
return perm == 'modeladmin.add_concert'
|
||||
|
||||
class MockChangeUser(MockUser):
|
||||
def has_perm(self, perm):
|
||||
return perm == 'modeladmin.change_band'
|
||||
@@ -797,26 +793,6 @@ class ModelAdminPermissionTests(SimpleTestCase):
|
||||
self.assertEqual(len(inline_instances), 1)
|
||||
self.assertIsInstance(inline_instances[0], ConcertInline)
|
||||
|
||||
def test_inline_has_add_permission_without_obj(self):
|
||||
# This test will be removed in Django 3.1 when `obj` becomes a required
|
||||
# argument of has_add_permission() (#27991).
|
||||
class ConcertInline(TabularInline):
|
||||
model = Concert
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return super().has_add_permission(request)
|
||||
|
||||
class BandAdmin(ModelAdmin):
|
||||
inlines = [ConcertInline]
|
||||
|
||||
ma = BandAdmin(Band, AdminSite())
|
||||
request = MockRequest()
|
||||
request.user = self.MockAddUserWithInline()
|
||||
band = Band(name='The Doors', bio='', sign_date=date(1965, 1, 1))
|
||||
inline_instances = ma.get_inline_instances(request, band)
|
||||
self.assertEqual(len(inline_instances), 1)
|
||||
self.assertIsInstance(inline_instances[0], ConcertInline)
|
||||
|
||||
def test_has_change_permission(self):
|
||||
"""
|
||||
has_change_permission returns True for users who can edit objects and
|
||||
|
||||
Reference in New Issue
Block a user