def handle(self, *args, **options): from bambu.navigation import site, autodiscover autodiscover() print print 'You can use the following menu partials in your NAVIGATION_MENUS setting' for (name, description) in site._partials: print '- %s%s' % (name.ljust(20, ' '), description) names = ', '.join(["'%s'" % n for (n, d) in site._partials]) print print 'For example:' print print '>>> NAVIGATION_MENUS = (\n... \t\'your-menu-key\', (' + names + ')\n... )' print print 'This will create a menu that contains all of the above items' print print 'To include this menu in your template, add' print print '{% load navigation %}\n{% menu \'your-menu-key\' %}...{% endmenu %}' print
from django.template import Node, Variable, Context, Library, TemplateSyntaxError, VariableDoesNotExist from django.core.urlresolvers import reverse, resolve from django.conf import settings from django.utils.safestring import mark_safe from bambu.navigation import site, autodiscover, DEFAULT_NAVIGATION_MENUS from bambu.navigation.auth import * from copy import deepcopy import shlex register = Library() if not site._discovered: autodiscover() menu_dict = {} for (menu, partials) in getattr(settings, 'NAVIGATION_MENUS', DEFAULT_NAVIGATION_MENUS): menu_dict[menu] = partials class CycleNode(Node): def __init__(self, key, nodelist, args, partial = False): self.key = key self.nodelist = nodelist self.args = args self.partial = partial def render(self, context): key = Variable(self.key).resolve(context) if not key in menu_dict and not self.partial: raise TemplateSyntaxError('Menu %s not found in settings.NAVIGATION_MENUS' % key) if not self.partial: partials = menu_dict[key]
from django.template import Node, Variable, Context, Library, TemplateSyntaxError, VariableDoesNotExist from django.core.urlresolvers import reverse, resolve from django.conf import settings from django.utils.safestring import mark_safe from bambu.navigation import site, autodiscover, DEFAULT_NAVIGATION_MENUS from bambu.navigation.auth import * from copy import deepcopy import shlex register = Library() if not site._discovered: autodiscover() menu_dict = {} for (menu, partials) in getattr(settings, 'NAVIGATION_MENUS', DEFAULT_NAVIGATION_MENUS): menu_dict[menu] = partials class CycleNode(Node): def __init__(self, key, nodelist, args, partial=False): self.key = key self.nodelist = nodelist self.args = args self.partial = partial def render(self, context): key = Variable(self.key).resolve(context) if not key in menu_dict and not self.partial: raise TemplateSyntaxError( 'Menu %s not found in settings.NAVIGATION_MENUS' % key)