David Jean Louis avatar David Jean Louis committed e443a3d

Updated custom dashboard and menu template files to reflect the current code (fixes #57 and #58)

Comments (0)

Files changed (2)

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

+"""
+This file was generated with the customdashboard management command, it
+contains the two classes for the main dashboard and app index dashboard.
+You can customize these classes as you want.
+
+To activate your index dashboard add the following to your settings.py::
+    ADMIN_TOOLS_INDEX_DASHBOARD = '{{ project }}.{{ file }}.CustomIndexDashboard'
+
+And to activate the app index dashboard::
+    ADMIN_TOOLS_APP_INDEX_DASHBOARD = '{{ project }}.{{ file }}.CustomAppIndexDashboard'
+"""
+
 from django.utils.translation import ugettext_lazy as _
 from django.core.urlresolvers import reverse
+
 from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
+from admin_tools.utils import get_admin_site_name
 
-# to activate your index dashboard add the following to your settings.py:
-#
-# ADMIN_TOOLS_INDEX_DASHBOARD = '{{ project }}.{{ file }}.CustomIndexDashboard'
 
 class CustomIndexDashboard(Dashboard):
     """
     Custom index dashboard for {{ project }}.
     """
-    def __init__(self, **kwargs):
-        Dashboard.__init__(self, **kwargs)
-
+    def init_with_context(self, context):
+        site_name = get_admin_site_name(context)
         # append a link list module for "quick links"
         self.children.append(modules.LinkList(
-            title=_('Quick links'),
+            _('Quick links'),
             layout='inline',
             draggable=False,
             deletable=False,
             collapsible=False,
             children=[
                 [_('Return to site'), '/'],
-                [_('Change password'), reverse('admin:password_change')],
-                [_('Log out'), reverse('admin:logout')],
+                [_('Change password'),
+                 reverse('%s:password_change' % site_name)],
+                [_('Log out'), reverse('%s:logout' % site_name)],
             ]
         ))
 
         # 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'),
-            limit=5
-        ))
+        self.children.append(modules.RecentActions(_('Recent Actions'), 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'),
             ]
         ))
 
-    def init_with_context(self, context):
-        """
-        Use this method if you need to access the request context.
-        """
-        pass
-
-
-# to activate your app index dashboard add the following to your settings.py:
-#
-# ADMIN_TOOLS_APP_INDEX_DASHBOARD = '{{ project }}.{{ file }}.CustomAppIndexDashboard'
 
 class CustomAppIndexDashboard(AppIndexDashboard):
     """
     Custom app index dashboard for {{ project }}.
     """
+
+    # 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,
+            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
         ))
 
     def init_with_context(self, context):
         """
         Use this method if you need to access the request context.
         """
-        pass
+        return super(CustomAppIndexDashboard, self).init_with_context(context)

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

+"""
+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::
+    ADMIN_TOOLS_MENU = '{{ project }}.{{ file }}.CustomMenu'
+"""
+
 from django.core.urlresolvers import reverse
 from django.utils.translation import ugettext_lazy as _
+
 from admin_tools.menu import items, Menu
 
-# to activate your custom menu add the following to your settings.py:
-#
-# ADMIN_TOOLS_MENU = '{{ project }}.{{ file }}.CustomMenu'
 
 class CustomMenu(Menu):
     """
         """
         Use this method if you need to access the request context.
         """
-        pass
+        return super(CustomMenu, self).init_with_context(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.