def init_with_context(self, context): if self.is_user_allowed(context.get('request').user): admin_site_name = get_admin_site_name(context) self.children += [ items.MenuItem( title=_('Dashboard'), icon='fa-tachometer', url=reverse('%s:index' % admin_site_name), description=_('Dashboard'), ), items.AppList( title=_('Applications'), description=_('Applications'), exclude=('django.contrib.*', ), icon='fa-tasks', ), items.AppList( title=_('Administration'), description=_('Administration'), models=('django.contrib.*', ), icon='fa-cog', ), ]
def _get_admin_app_list_url(self, model, context): """ Returns the admin change url. """ app_label = model._meta.app_label return reverse('%s:app_list' % get_admin_site_name(context), args=(app_label,))
def init_with_context(self, context): admin_site_name = get_admin_site_name(context) if 'django.contrib.sites' in settings.INSTALLED_APPS: from django.contrib.sites.models import Site site_name = Site.objects.get_current().name site_url = 'http://' + Site.objects.get_current().domain else: site_name = _('Site') site_url = '/' self.children += [ items.MenuItem( title=site_name, url=site_url, icon='fa-bullseye', css_styles='font-size: 1.5em;', ), items.MenuItem( title=_('Dashboard'), icon='fa-tachometer', url=reverse('%s:index' % admin_site_name), description=_('Dashboard'), ), items.UserTools( css_styles='float: right;', is_user_allowed=lambda user: user.is_staff, ), ]
def _get_admin_add_url(self, model, context): """ Returns the admin add url. """ app_label = model._meta.app_label return reverse('%s:%s_%s_add' % (get_admin_site_name(context), app_label, model.__name__.lower()))
def render(self, context): menu = get_menu(self.menu_name, get_admin_site_name(context)) if menu and menu.is_user_allowed(context.get('request').user): enabled = True else: enabled = False context['wpadmin_is_%s_menu_enabled' % self.menu_name] = enabled return ''
def wpadmin_render_custom_style(context): custom_style_path = get_wpadmin_settings(get_admin_site_name(context)) \ .get('custom_style', None) if custom_style_path: return '<link type="text/css" rel="stylesheet" href="%s" />' \ % custom_style_path else: return ''
def wpadmin_render_left_menu(context): menu = get_menu('left', get_admin_site_name(context)) if menu: menu.init_with_context(context) context.update({ 'menu': menu, 'is_user_allowed': menu.is_user_allowed(context.get('request').user), }) return context
def wpadmin_render_top_menu(context): menu = get_menu('top', get_admin_site_name(context)) if not menu: # from wpadmin.menu.menus import DefaultTopMenu from box.wpadmin.menu.menus import DefaultTopMenu menu = DefaultTopMenu() menu.init_with_context(context) context.update({ 'menu': menu, 'is_user_allowed': menu.is_user_allowed(context.get('request').user), }) return context
def wpadmin_render_custom_title(context): # Translators: This is already translated in Django return get_wpadmin_settings(get_admin_site_name(context)) \ .get('title', context.get('site_title', _('Django site admin')))
def render(self, context): context['wpadmin_are_breadcrumbs_enabled'] = are_breadcrumbs_enabled( get_admin_site_name(context)) return ''