From f9ff1df1daac8ae1fc22b27f48735148cb5488dd Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Sat, 10 Nov 2018 00:52:30 +0100 Subject: Fixed #29917 -- Stopped collecting ModelAdmin.actions from base ModelAdmins. --- tests/modeladmin/test_actions.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/modeladmin') diff --git a/tests/modeladmin/test_actions.py b/tests/modeladmin/test_actions.py index 17b3c324d2..a33c1811b2 100644 --- a/tests/modeladmin/test_actions.py +++ b/tests/modeladmin/test_actions.py @@ -55,3 +55,24 @@ class AdminActionsTests(TestCase): mock_request.user = user actions = ma.get_actions(mock_request) self.assertEqual(list(actions.keys()), expected) + + def test_actions_inheritance(self): + class AdminBase(admin.ModelAdmin): + actions = ['custom_action'] + + def custom_action(modeladmin, request, queryset): + pass + + class AdminA(AdminBase): + pass + + class AdminB(AdminBase): + actions = None + + ma1 = AdminA(Band, admin.AdminSite()) + action_names = [name for _, name, _ in ma1._get_base_actions()] + self.assertEqual(action_names, ['delete_selected', 'custom_action']) + # `actions = None` removes actions from superclasses. + ma2 = AdminB(Band, admin.AdminSite()) + action_names = [name for _, name, _ in ma2._get_base_actions()] + self.assertEqual(action_names, ['delete_selected']) -- cgit v1.3