Ejemplo n.º 1
0
def grp_render_dashboard(context, location='index', dashboard=None):
    """
    Template tag that renders the dashboard, it takes two optional arguments:
    
    ``location``
        The location of the dashboard, it can be 'index' (for the admin index
        dashboard) or 'app_index' (for the app index dashboard), the default
        value is 'index'.
    
    ``dashboard``
        An instance of ``Dashboard``, if not given, the dashboard is retrieved
        with the ``get_index_dashboard`` or ``get_app_index_dashboard``
        functions, depending on the ``location`` argument.
    """

    if dashboard is None:
        dashboard = get_index_dashboard(context)
    
    dashboard.init_with_context(context)
    
    context.update({
        'template': dashboard.template,
        'dashboard': dashboard,
        'admin_url': reverse('%s:index' % get_admin_site_name(context)),
    })
    return context
Ejemplo n.º 2
0
 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(
         _('Quick links'),
         collapsible=False,
         children=[
             [_('Return to site'), '/'],
             [_('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(
         _('Applications'),
         exclude=('django.contrib.*',),
     ))
     
     # append an app list module for "Administration"
     self.children.append(modules.AppList(
         _('Administration'),
         models=('django.contrib.*',),
     ))
     
     # append a recent actions module
     self.children.append(modules.RecentActions(_('Recent Actions'), 5))
     
     # append a feed module
     self.children.append(modules.Feed(
         _('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(
         _('Support'),
         children=[
             {
                 'title': _('Django documentation'),
                 'url': 'http://docs.djangoproject.com/',
                 'external': True,
             },
             {
                 'title': _('Django "django-users" mailing list'),
                 'url': 'http://groups.google.com/group/django-users',
                 'external': True,
             },
             {
                 'title': _('Django irc channel'),
                 'url': 'irc://irc.freenode.net/django',
                 'external': True,
             },
         ]
     ))
Ejemplo n.º 3
0
def grp_render_dashboard_module(context, module, index=None, subindex=None):
    """
    Template tag that renders a given dashboard module, it takes a
    ``DashboardModule`` instance as first parameter and an integer ``index`` as
    second parameter, that is the index of the module in the dashboard.
    """
    
    module.init_with_context(context)
    context.update({
        'template': module.template,
        'module': module,
        'index': index,
        'subindex': subindex,
        'admin_url': reverse('%s:index' % get_admin_site_name(context)),
    })
    return context