2014-10-11 03:54:24 +00:00
|
|
|
"""
|
|
|
|
|
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 = 'admin_tools_dashboard.menu.CustomMenu'
|
|
|
|
|
"""
|
|
|
|
|
|
2022-07-12 20:53:28 +00:00
|
|
|
from admin_tools.menu import Menu, items
|
2014-11-18 23:47:07 +00:00
|
|
|
from django.conf import settings
|
2022-08-07 00:36:23 +00:00
|
|
|
from django.urls import reverse
|
2020-01-11 00:46:53 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2014-10-11 03:54:24 +00:00
|
|
|
|
2016-10-20 22:19:59 +00:00
|
|
|
from . import conf
|
|
|
|
|
|
2022-07-12 20:53:28 +00:00
|
|
|
__all__ = ("CustomMenu",)
|
2016-10-20 22:19:59 +00:00
|
|
|
|
2014-10-11 03:54:24 +00:00
|
|
|
|
|
|
|
|
class CustomMenu(Menu):
|
2016-10-20 22:19:59 +00:00
|
|
|
"""Custom Menu."""
|
|
|
|
|
|
2014-10-11 03:54:24 +00:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
|
Menu.__init__(self, **kwargs)
|
|
|
|
|
self.children += [
|
2022-07-12 20:53:28 +00:00
|
|
|
items.MenuItem(_("Dashboard"), reverse("admin:index")),
|
2014-10-11 03:54:24 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Foo
|
2022-07-12 20:53:28 +00:00
|
|
|
self.children.append(items.ModelList(_("Foo"), models=conf.foo_apps))
|
2014-10-11 03:54:24 +00:00
|
|
|
|
|
|
|
|
# Fobi
|
2016-11-16 23:07:06 +00:00
|
|
|
self.children.append(
|
|
|
|
|
items.MenuItem(
|
2022-07-12 20:53:28 +00:00
|
|
|
_("Fobi"),
|
2016-11-16 23:07:06 +00:00
|
|
|
children=[
|
2022-07-12 20:53:28 +00:00
|
|
|
items.ModelList(_("Plugins"), models=conf.fobi_plugins),
|
|
|
|
|
items.ModelList(_("Forms"), models=conf.fobi_forms),
|
|
|
|
|
items.ModelList(_("Data"), models=conf.fobi_data),
|
|
|
|
|
],
|
2016-11-16 23:07:06 +00:00
|
|
|
)
|
|
|
|
|
)
|
2014-10-11 03:54:24 +00:00
|
|
|
|
2022-07-12 20:53:28 +00:00
|
|
|
if "feincms" in settings.INSTALLED_APPS:
|
2014-11-18 23:47:07 +00:00
|
|
|
# FeinCMS pages integration
|
2016-11-16 23:07:06 +00:00
|
|
|
self.children.append(
|
2022-07-12 20:53:28 +00:00
|
|
|
items.AppList(_("FeinCMS Pages"), models=conf.feincms_pages)
|
2016-11-16 23:07:06 +00:00
|
|
|
)
|
2014-11-18 23:47:07 +00:00
|
|
|
|
2022-07-12 20:53:28 +00:00
|
|
|
if "cms" in settings.INSTALLED_APPS:
|
2014-11-18 23:47:07 +00:00
|
|
|
# DjangoCMS pages integration
|
2016-11-16 23:07:06 +00:00
|
|
|
self.children.append(
|
2022-07-12 20:53:28 +00:00
|
|
|
items.AppList(_("DjangoCMS Pages"), models=conf.djangocms_pages)
|
2016-11-16 23:07:06 +00:00
|
|
|
)
|
2014-10-11 03:54:24 +00:00
|
|
|
|
|
|
|
|
# append an app list module for "Administration"
|
2016-11-16 23:07:06 +00:00
|
|
|
self.children.append(
|
2022-07-12 20:53:28 +00:00
|
|
|
items.AppList(_("Administration"), models=["django.contrib.*"])
|
2016-11-16 23:07:06 +00:00
|
|
|
)
|
2014-10-11 03:54:24 +00:00
|
|
|
|
|
|
|
|
def init_with_context(self, context):
|
2016-10-20 22:19:59 +00:00
|
|
|
"""Use this method if you need to access the request context."""
|
2014-10-11 03:54:24 +00:00
|
|
|
return super(CustomMenu, self).init_with_context(context)
|