-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.py
40 lines (32 loc) · 1.29 KB
/
menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
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 = 'Cofivi.menu.CustomMenu'
"""
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.text import capfirst
from admin_tools.menu import items, Menu
from admin_tools.menu.items import MenuItem
from django.db.models import Q
class CustomAppList(items.AppList):
def init_with_context(self, context):
items = self._visible_models(context['request'])
for model, perms in items:
if not perms['change']:
continue
item = MenuItem(title=capfirst(model._meta.verbose_name_plural), url=self._get_admin_change_url(model, context))
self.children.append(item)
class CustomMenu(Menu):
def __init__(self, **kwargs):
Menu.__init__(self, **kwargs)
self.children += [
items.MenuItem(_('Dashboard'), reverse('admin:index')),
items.Bookmarks(u'Favoritos'),
CustomAppList(
u'Adminstração',
models=('django.contrib.*', ),
),
]