From 1916f7cba479a4b026199c81bae7f252a98a66ea Mon Sep 17 00:00:00 2001 From: Daniel Greenfeld Date: Fri, 31 May 2013 15:37:55 +0200 Subject: [PATCH] Change list actions to be list_actions so their nature is more explicit --- djadmin2/constants.py | 2 +- djadmin2/types.py | 9 +++------ djadmin2/views.py | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/djadmin2/constants.py b/djadmin2/constants.py index 3951312..b21d6b7 100644 --- a/djadmin2/constants.py +++ b/djadmin2/constants.py @@ -3,6 +3,6 @@ from django.conf import settings MODEL_ADMIN_ATTRS = ( 'list_display', 'list_display_links', 'list_filter', 'admin', 'index_view', 'detail_view', 'create_view', 'update_view', 'delete_view', - 'get_default_view_kwargs', 'get_actions') + 'get_default_view_kwargs', 'get_list_actions') ADMIN2_THEME_DIRECTORY = getattr(settings, "ADMIN2_THEME_DIRECTORY", "admin2/bootstrap") diff --git a/djadmin2/types.py b/djadmin2/types.py index 283cf41..19e718c 100644 --- a/djadmin2/types.py +++ b/djadmin2/types.py @@ -45,7 +45,7 @@ class ModelAdmin2(object): list_fields = [] #This shows up on the DocumentListView of the Posts - list_actions = [] + list_actions = [actions.delete_selected] # This shows up in the DocumentDetailView of the Posts. document_actions = [] @@ -84,9 +84,6 @@ class ModelAdmin2(object): api_list_view = apiviews.ListCreateAPIView api_detail_view = apiviews.RetrieveUpdateDestroyAPIView - # Actions - actions = [actions.delete_selected] - def __init__(self, model, admin, name=None, **kwargs): self.name = name self.model = model @@ -214,11 +211,11 @@ class ModelAdmin2(object): def api_urls(self): return self.get_api_urls(), None, None - def get_actions(self): + def get_list_actions(self): actions_dict = {} for cls in type(self).mro()[::-1]: - class_actions = getattr(cls, 'actions', []) + class_actions = getattr(cls, 'list_actions', []) for action in class_actions: actions_dict[action.__name__] = { 'name': action.__name__, diff --git a/djadmin2/views.py b/djadmin2/views.py index 268b3c9..bb8ee49 100644 --- a/djadmin2/views.py +++ b/djadmin2/views.py @@ -75,7 +75,7 @@ class ModelListView(AdminModel2Mixin, generic.ListView): return reverse(view_name) def get_actions(self): - return self.model_admin.get_actions() + return self.model_admin.get_list_actions() class ModelDetailView(AdminModel2Mixin, generic.DetailView):