stats view protections
[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
14 def __init__(self, **kwargs):
15 Menu.__init__(self, **kwargs)
16 self.children.append(items.MenuItem(
17 title=_('Dashboard'),
18 url=reverse('admin:index')
19 ))
20 self.children.append(items.AppList(
21 title=_('Applications'),
22 exclude_list=('django.contrib',)
23 ))
24 self.children.append(items.AppList(
25 title=_('Administration'),
26 include_list=('django.contrib',)
27 ))
28
29 def init_with_context(self, context):
30 """
31 Use this method if you need to access the request context.
32 """
33 request = context['request']
34 if request.user.has_perm('savoirs.statistiques'):
35 self.children.append(self.statistiques)