Mikhail Korobov avatar Mikhail Korobov committed 1e30d5b

include_list and exclude_list are now deprecated for ModelList and AppList

Comments (0)

Files changed (9)

admin_tools/dashboard/dashboards.py

                 # append an app list module for "Applications"
                 self.children.append(modules.AppList(
                     title=_('Applications'),
-                    exclude_list=('django.contrib',),
+                    exclude=('django.contrib.*',),
                 ))
 
                 # append an app list module for "Administration"
                 self.children.append(modules.AppList(
                     title=_('Administration'),
-                    include_list=('django.contrib',),
+                    models=('django.contrib.*',),
                 ))
 
                 # append a recent actions module
                 # append a model list module that lists all models
                 # for the app and a recent actions module for the current app
                 self.children += [
-                    modules.ModelList(self.app_title, include_list=self.models),
+                    modules.ModelList(self.app_title, self.models),
                     modules.RecentActions(
                         include_list=self.models,
                         limit=5
         # append an app list module for "Applications"
         self.children.append(modules.AppList(
             _('Applications'),
-            exclude_list=('django.contrib',),
+            exclude=('django.contrib.*',),
         ))
 
         # append an app list module for "Administration"
         self.children.append(modules.AppList(
             _('Administration'),
-            include_list=('django.contrib',),
+            models=('django.contrib.*',),
         ))
 
         # append a recent actions module
     def __init__(self, *args, **kwargs):
         AppIndexDashboard.__init__(self, *args, **kwargs)
 
-        # append a model list module
-        self.children.append(modules.ModelList(
-            self.app_title,
-            include_list=self.models,
-        ))
-
-        # append a recent actions module
-        self.children.append(modules.RecentActions(
-            _('Recent Actions'),
-            include_list=self.get_app_content_types(),
-            limit=5
-        ))
+        # append a model list module and a recent actions module
+        self.children += [
+            modules.ModelList( self.app_title,self.models),
+            modules.RecentActions(
+                _('Recent Actions'),
+                include_list=self.get_app_content_types(),
+                limit=5
+            )
+        ]

admin_tools/dashboard/modules.py

                     children=[
                         modules.AppList(
                             title='Administration',
-                            include_list=('django.contrib',)
+                            models=('django.contrib.*',)
                         ),
                         modules.AppList(
                             title='Applications',
-                            exclude_list=('django.contrib',)
+                            exclude=('django.contrib.*',)
                         )
                     ]
                 ))
 
     def is_empty(self):
         """
-        A group of modules is considered empty if it has no children or if 
+        A group of modules is considered empty if it has no children or if
         all its children are empty.
 
         >>> from admin_tools.dashboard.modules import DashboardModule, LinkList
     properties, the :class:`~admin_tools.dashboard.modules.AppList`
     has two extra properties:
 
-    ``exclude_list``
-        A list of apps to exclude, if an app name (e.g. "django.contrib.auth"
-        starts with an element of this list (e.g. "django.contrib") it won't
-        appear in the dashboard module.
+    ``models``
+        A list of models to include, only models whose name (e.g.
+        "blog.comments.Comment") match one of the strings (e.g. "blog.*")
+        in the models list will appear in the dashboard module.
 
-    ``include_list``
-        A list of apps to include, only apps whose name (e.g.
-        "django.contrib.auth") starts with one of the strings (e.g.
-        "django.contrib") in the list will appear in the dashboard module.
+    ``exclude``
+        A list of models to exclude, if a model name (e.g.
+        "blog.comments.Comment") match an element of this list (e.g.
+        "blog.comments.*") it won't appear in the dashboard module.
 
-    If no include/exclude list is provided, **all apps** are shown.
+    If no models/exclude list is provided, **all apps** are shown.
 
     Here's a small example of building an app list module::
 
                 # will only list the django.contrib apps
                 self.children.append(modules.AppList(
                     title='Administration',
-                    include_list=('django.contrib',)
+                    models=('django.contrib.*',)
                 ))
                 # will list all apps except the django.contrib ones
                 self.children.append(modules.AppList(
                     title='Applications',
-                    exclude_list=('django.contrib',)
+                    exclude=('django.contrib.*',)
                 ))
 
     The screenshot of what this code produces:
     exclude_list = None
 
     def __init__(self, title=None, **kwargs):
-        self.include_list = kwargs.pop('include_list', [])
-        self.exclude_list = kwargs.pop('exclude_list', [])
         self.models = list(kwargs.pop('models', []))
         self.exclude = list(kwargs.pop('exclude', []))
+        self.include_list = kwargs.pop('include_list', []) # deprecated
+        self.exclude_list = kwargs.pop('exclude_list', []) # deprecated
         super(AppList, self).__init__(title, **kwargs)
 
     def init_with_context(self, context):
     ``models``
         A list of models to include, only models whose name (e.g.
         "blog.comments.Comment") match one of the strings (e.g. "blog.*")
-        in the include list will appear in the dashboard module.
+        in the models list will appear in the dashboard module.
 
     ``exclude``
         A list of models to exclude, if a model name (e.g.
-        "blog.comments.Comment" match an element of this list (e.g.
+        "blog.comments.Comment") match an element of this list (e.g.
         "blog.comments.*") it won't appear in the dashboard module.
 
     Here's a small example of building a model list module::

admin_tools/dashboard/templates/admin_tools/dashboard/dashboard.txt

         # append an app list module for "Applications"
         self.children.append(modules.AppList(
             _('Applications'),
-            exclude_list=('django.contrib',),
+            exclude=('django.contrib.*',),
         ))
 
         # append an app list module for "Administration"
         self.children.append(modules.AppList(
             _('Administration'),
-            include_list=('django.contrib',),
+            models=('django.contrib.*',),
         ))
 
         # append a recent actions module
     def __init__(self, *args, **kwargs):
         AppIndexDashboard.__init__(self, *args, **kwargs)
 
-        # append a model list module
-        self.children.append(modules.ModelList(
-            self.app_title,
-            include_list=self.models,
-        ))
-
-        # append a recent actions module
-        self.children.append(modules.RecentActions(
-            _('Recent Actions'),
-            include_list=self.get_app_content_types(),
-            limit=5
-        ))
+        # append a model list module and a recent actions module
+        self.children += [
+            modules.ModelList(self.app_title, self.models),
+            modules.RecentActions(
+                _('Recent Actions'),
+                include_list=self.get_app_content_types(),
+                limit=5
+            )
+        ]
 
     def init_with_context(self, context):
         """

admin_tools/menu/items.py

     In addition to the parent :class:`~admin_tools.menu.items.MenuItem`
     properties, the ``AppList`` has two extra properties:
 
-    ``exclude_list``
-        A list of apps to exclude, if an app name (e.g. "django.contrib.auth"
-        starts with an element of this list (e.g. "django.contrib") it won't
-        appear in the menu item.
+    ``models``
+        A list of models to include, only models whose name (e.g.
+        "blog.comments.Comment") match one of the strings (e.g. "blog.*")
+        in the models list will appear in the menu item.
 
-    ``include_list``
-        A list of apps to include, only apps whose name (e.g.
-        "django.contrib.auth") starts with one of the strings (e.g.
-        "django.contrib") in the list will appear in the menu item.
+    ``exclude``
+        A list of models to exclude, if a model name (e.g.
+        "blog.comments.Comment") match an element of this list (e.g.
+        "blog.comments.*") it won't appear in the menu item.
 
-    If no include/exclude list is provided, **all apps** are shown.
+
+    If no models/exclude list is provided, **all apps** are shown.
 
     Here's a small example of building an app list menu item::
 
         """
         ``AppListMenuItem`` constructor.
         """
-        self.include_list = kwargs.pop('include_list', [])
-        self.exclude_list = kwargs.pop('exclude_list', [])
         self.models = list(kwargs.pop('models', []))
         self.exclude = list(kwargs.pop('exclude', []))
+        self.include_list = kwargs.pop('include_list', []) # deprecated
+        self.exclude_list = kwargs.pop('exclude_list', []) # deprecated
         super(AppList, self).__init__(title, **kwargs)
 
 

admin_tools/menu/menus.py

             items.Bookmarks(),
             items.AppList(
                 _('Applications'),
-                exclude_list=('django.contrib',)
+                exclude=('django.contrib.*',)
             ),
             items.AppList(
                 _('Administration'),
-                include_list=('django.contrib',)
+                models=('django.contrib.*',)
             )
         ]

admin_tools/menu/templates/admin_tools/menu/menu.txt

 """
-This file was generated with the custommenu management command, it contains 
+This file was generated with the custommenu management command, it contains
 the classes for the admin menu, you can customize this class as you want.
 
 To activate your custom menu add the following to your settings.py::
             items.Bookmarks(),
             items.AppList(
                 _('Applications'),
-                exclude_list=('django.contrib',)
+                exclude=('django.contrib.*',)
             ),
             items.AppList(
                 _('Administration'),
-                include_list=('django.contrib',)
+                models=('django.contrib.*',)
             )
         ]
 

admin_tools/utils.py

 from django.contrib import admin
 from django.core.urlresolvers import reverse
 from django.utils.importlib import import_module
+import warnings
 
 
 def get_admin_site(context=None, request=None):
         'ADMIN_TOOLS_INDEX_DASHBOARD',
         'admin_tools.dashboard.dashboards.DefaultIndexDashboard'
     )
-    
+
     if type(dashboard_cls) is types.DictType:
         if context:
             request = context.get('request')
     """ Returns (model, perm,) for all models user can possibly see """
     items = []
     admin_site = get_admin_site(request=request)
-    
+
     for model, model_admin in admin_site._registry.items():
         perms = model_admin.get_model_perms(request)
         if True not in perms.values():
     def _visible_models(self, request):
         # compatibility layer: generate models/exclude patterns
         # from include_list/exclude_list args
+
+        if self.include_list:
+            warnings.warn(
+               "`include_list` is deprecated for ModelList and AppList and "
+               "will be removed in future releases. Please use `models` instead.",
+               DeprecationWarning
+            )
+
+        if self.exclude_list:
+            warnings.warn(
+               "`exclude_list` is deprecated for ModelList and AppList and "
+               "will be removed in future releases. Please use `exclude` instead.",
+               DeprecationWarning
+            )
+
         included = self.models[:]
         included.extend([elem+"*" for elem in self.include_list])
 
         if self.exclude_list and not included:
             included = ["*"]
         return filter_models(request, included, excluded)
-    
+
     def _get_admin_app_list_url(self, model, context):
         """
         Returns the admin change url.
         app_label = model._meta.app_label
         return reverse('%s:app_list' % get_admin_site_name(context),
                        args=(app_label,))
-    
+
     def _get_admin_change_url(self, model, context):
         """
         Returns the admin change url.
         return reverse('%s:%s_%s_changelist' % (get_admin_site_name(context),
                                                 app_label,
                                                 model.__name__.lower()))
-    
+
     def _get_admin_add_url(self, model, context):
         """
         Returns the admin add url.

test_proj/dashboard.py

         # append an app list module for "Applications"
         self.children.append(modules.AppList(
             _('Applications'),
-            exclude_list=('django.contrib',),
+            exclude=['django.contrib.*'],
         ))
 
         # append an app list module for "Administration"
         self.children.append(modules.AppList(
             _('Administration'),
-            include_list=('django.contrib',),
+            models=('django.contrib.*',),
         ))
 
         self.children.append(modules.ModelList(
         AppIndexDashboard.__init__(self, *args, **kwargs)
 
         self.children += [
-            modules.ModelList(self.app_title, include_list=self.models),
+            modules.ModelList(self.app_title, self.models),
             modules.RecentActions(include_list=self.get_app_content_types()),
         ]
 

test_proj/menu.py

             items.Bookmarks(),
             items.AppList(
                 _('Applications'),
-                exclude_list=('django.contrib',)
+                exclude=('django.contrib.*',)
             ),
             items.AppList(
                 _('Administration'),
-                include_list=('django.contrib',)
+                models=('django.contrib.*',)
             ),
             items.ModelList(
                 'Test app menu',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.