Commits

Mikhail Korobov committed fbda761

Dashboard modules' constructors now have 'title' positional argument

Comments (0)

Files changed (3)

admin_tools/dashboard/dashboards.py

 
         # append a link list module for "quick links"
         self.children.append(modules.LinkList(
-            title=_('Quick links'),
+            _('Quick links'),
             layout='inline',
             draggable=False,
             deletable=False,
 
         # append an app list module for "Applications"
         self.children.append(modules.AppList(
-            title=_('Applications'),
+            _('Applications'),
             exclude_list=('django.contrib',),
         ))
 
         # append an app list module for "Administration"
         self.children.append(modules.AppList(
-            title=_('Administration'),
+            _('Administration'),
             include_list=('django.contrib',),
         ))
 
         # append a recent actions module
         self.children.append(modules.RecentActions(
-            title=_('Recent Actions'),
+            _('Recent Actions'),
             limit=5
         ))
 
         # append a feed module
         self.children.append(modules.Feed(
-            title=_('Latest Django News'),
+            _('Latest Django News'),
             feed_url='http://www.djangoproject.com/rss/weblog/',
             limit=5
         ))
 
         # append another link list module for "support".
         self.children.append(modules.LinkList(
-            title=_('Support'),
+            _('Support'),
             children=[
                 {
                     'title': _('Django documentation'),
 
         # append a model list module
         self.children.append(modules.ModelList(
-            title=self.app_title,
+            self.app_title,
             include_list=self.models,
         ))
 
         # append a recent actions module
         self.children.append(modules.RecentActions(
-            title=_('Recent Actions'),
+            _('Recent Actions'),
             include_list=self.get_app_content_types(),
             limit=5
         ))

admin_tools/dashboard/modules.py

     post_content = None
     children = None
 
-    def __init__(self, **kwargs):
+    def __init__(self, title=None, **kwargs):
+        if title is not None:
+            self.title = title
         for key in kwargs:
             if hasattr(self.__class__, key):
                 setattr(self, key, kwargs[key])
     include_list = None
     exclude_list = None
 
-    def __init__(self, **kwargs):
+    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', []))
-        super(AppList, self).__init__(**kwargs)
+        super(AppList, self).__init__(title, **kwargs)
 
     def init_with_context(self, context):
         items = self._visible_models(context['request'])
 
     template = 'admin_tools/dashboard/modules/model_list.html'
 
-    def __init__(self, **kwargs):
+    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', []))
-        super(ModelList, self).__init__(**kwargs)
+        super(ModelList, self).__init__(title, **kwargs)
 
     def init_with_context(self, context):
         items = self._visible_models(context['request'])
     template = 'admin_tools/dashboard/modules/recent_actions.html'
     limit = 10
 
-    def __init__(self, **kwargs):
+    def __init__(self, title=None, **kwargs):
         self.include_list = kwargs.pop('include_list', [])
         self.exclude_list = kwargs.pop('exclude_list', [])
-        super(RecentActions, self).__init__(**kwargs)
+        super(RecentActions, self).__init__(title, **kwargs)
 
     def init_with_context(self, context):
         from django.db.models import Q

test_proj/dashboard.py

 
         # append a link list module for "quick links"
         self.children.append(modules.LinkList(
-            title=_('Quick links'),
+            _('Quick links'),
             layout='inline',
             draggable=False,
             deletable=False,
 
         # append an app list module for "Applications"
         self.children.append(modules.AppList(
-            title=_('Applications'),
+            _('Applications'),
             exclude_list=('django.contrib',),
         ))
 
         # append an app list module for "Administration"
         self.children.append(modules.AppList(
-            title=_('Administration'),
+            _('Administration'),
             include_list=('django.contrib',),
         ))
 
         self.children.append(modules.ModelList(
-            title='Test1',
+            'Test1',
             models = ['django.contrib.auth.*', '*.Site', '*.Foo'],
             exclude = ['django.contrib.auth.models.User', 'test_app.*']
         ))
 
         # append a recent actions module
         self.children.append(modules.RecentActions(
-            title=_('Recent Actions'),
+            _('Recent Actions'),
             limit=5
         ))
 
         # append another link list module for "support".
         self.children.append(modules.LinkList(
-            title=_('Support'),
+            _('Support'),
             children=[
                 {
                     'title': _('Django documentation'),
     """
     Custom app index dashboard for test_proj.
     """
+
+    # we disable title because its redundant with the model list module
+    title = ''
+
     def __init__(self, *args, **kwargs):
         AppIndexDashboard.__init__(self, *args, **kwargs)
 
-        # we disable title because its redundant with the model list module
-        self.title = ''
-
-        # append a model list module
-        self.children.append(modules.ModelList(
-            title=self.app_title,
-            include_list=self.models,
-        ))
-
-        # append a recent actions module
-        self.children.append(modules.RecentActions(
-            title=_('Recent Actions'),
-            include_list=self.get_app_content_types(),
-        ))
+        self.children += [
+            modules.ModelList(self.app_title, include_list=self.models),
+            modules.RecentActions(include_list=self.get_app_content_types()),
+        ]
 
     def init_with_context(self, context):
         """
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.