diff options
| author | hashlash <muh.ashlah@gmail.com> | 2020-03-20 14:24:14 +0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-17 20:23:00 +0200 |
| commit | dfbd9ca065728b543cc756359079a1b51d10841a (patch) | |
| tree | 259d7fcfebd46968e5838c596f5ff8f68ebbbd8e /tests/modeladmin | |
| parent | 75410228dfd16e49eb3c0ea30b59b4c0d2ea6b03 (diff) | |
Fixed #30311 -- Restored ability to override global admin actions.
Diffstat (limited to 'tests/modeladmin')
| -rw-r--r-- | tests/modeladmin/test_actions.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/modeladmin/test_actions.py b/tests/modeladmin/test_actions.py index a33c1811b2..76f2f96c03 100644 --- a/tests/modeladmin/test_actions.py +++ b/tests/modeladmin/test_actions.py @@ -76,3 +76,42 @@ class AdminActionsTests(TestCase): ma2 = AdminB(Band, admin.AdminSite()) action_names = [name for _, name, _ in ma2._get_base_actions()] self.assertEqual(action_names, ['delete_selected']) + + def test_actions_replace_global_action(self): + def global_action_1(modeladmin, request, queryset): + pass + + def global_action_2(modeladmin, request, queryset): + pass + + global_action_1.short_description = 'Site-wide admin action 1.' + global_action_2.short_description = 'Site-wide admin action 2.' + admin.site.add_action(global_action_1, name='custom_action_1') + admin.site.add_action(global_action_2, name='custom_action_2') + + def custom_action_1(modeladmin, request, queryset): + pass + + custom_action_1.short_description = 'Local admin action 1.' + + class BandAdmin(admin.ModelAdmin): + actions = [custom_action_1, 'custom_action_2'] + + def custom_action_2(self, request, queryset): + pass + + custom_action_2.short_description = 'Local admin action 2.' + + ma = BandAdmin(Band, admin.site) + self.assertEqual(ma.check(), []) + self.assertEqual( + [ + desc + for _, name, desc in ma._get_base_actions() + if name.startswith('custom_action') + ], + [ + 'Local admin action 1.', + 'Local admin action 2.', + ], + ) |
