Merge branch 'master' into test
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / menu.py
1 # coding: utf-8
2
3 from django.core.urlresolvers import reverse
4 from django.utils.translation import ugettext_lazy as _
5 from admin_tools.menu import items, Menu
6
7 class CustomMenu(Menu):
8 """
9 Custom Menu for sep admin site.
10 """
11
12 statistiques = items.MenuItem(title='Statistiques', url=reverse('stats'))
13 rappels = items.MenuItem(title='Rappels', url=reverse('admin-rappels'))
14
15 def __init__(self, **kwargs):
16 Menu.__init__(self, **kwargs)
17 self.children.append(items.MenuItem(
18 title=_('Dashboard'),
19 url=reverse('admin:index')
20 ))
21 self.children.append(items.AppList(
22 title=_('Applications'),
23 exclude_list=('django.contrib',)
24 ))
25 self.children.append(items.AppList(
26 title=_('Administration'),
27 include_list=('django.contrib',)
28 ))
29
30 def init_with_context(self, context):
31 """
32 Use this method if you need to access the request context.
33 """
34 request = context['request']
35 if request.user.has_perm('savoirs.statistiques'):
36 self.children.append(self.statistiques)
37
38 self.children.append(self.rappels)