#-*-encoding: utf-8-*- """ 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 = 'pensfond.admin_dashboard.CustomIndexDashboard' And to activate the app index dashboard:: ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'pensfond.admin_dashboard.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 class CustomIndexDashboard(Dashboard): """ Custom index dashboard for pensfond. """ 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'), # layout='inline', # draggable=False, # deletable=False, # collapsible=False, # children=[ # [_('Return to site'), '/'], # [_('Change password'), # reverse('%s:password_change' % site_name)], # [_('Log out'), reverse('%s:logout' % site_name)], # ] # )) user = context.get('user') perms_list = ['can_import_export_oblotdelen', 'can_import_export_naspunkts', 'can_import_export_naspunktotdelen', 'can_import_export_fond', 'can_import_export_fond_stats'] if user and user.has_perms(perms_list): self.children.append(modules.LinkList( u'Сервис', children=[ { 'title': u'Импорт центральных отделений', 'url': '/admin/pensfonds/import_obl_otdelen/', }, { 'title': u'Экспорт центральных отделений', 'url': '/admin/pensfonds/export_obl_otdelen/', }, { 'title': u'Импорт населенных пунктов', 'url': '/admin/pensfonds/import_naspunkts/', }, { 'title': u'Экспорт населенных пунктов', 'url': '/admin/pensfonds/export_naspunkts/', }, { 'title': u'Импорт отделений в нас. пунктах', 'url': '/admin/pensfonds/import_naspunkt_otdelen/', }, { 'title': u'Экспорт отделений в нас. пунктах', 'url': '/admin/pensfonds/export_naspunkt_otdelen/', }, { 'title': u'Сверка НПФ', 'url': '/admin/npfs/revise_licenses/', }, { 'title': u'Импорт основных показателей НПФ', 'url': '/admin/npfs/fond_stats/', }, ] )) # 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, # }, # ] # )) class CustomAppIndexDashboard(AppIndexDashboard): """ Custom app index dashboard for pensfond. """ # we disable title because its redundant with the model list module title = '' def __init__(self, *args, **kwargs): AppIndexDashboard.__init__(self, *args, **kwargs) # 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): """ Use this method if you need to access the request context. """ return super(CustomAppIndexDashboard, self).init_with_context(context)