コード例 #1
0
 def render(self, context):
     current_rule = get_value(self.current_rule, context)
     current_obj = get_value(self.current_obj, context)
     if current_rule is None:
         ancestors = []
     else:
         current = MenuItem(current_rule, current_obj)
         ancestors = current.ancestors()
     context['menuproxy_breadcrumbs'] = ancestors
     return u''
コード例 #2
0
    def render(self, context):
        if self.proxy:
            current = get_value(self.current_rule, context)
            target = get_value(self.current_obj, context, DoesNotDefined)
        else:
            current_rule = get_value(self.current_rule, context)
            current_obj = get_value(self.current_obj, context, DoesNotDefined)
            if current_rule is None:
                current = DoesNotDefined
            else:
                current = MenuItem(current_rule, current_obj)

            target_rule = get_value(self.target_rule, context)
            target_obj = get_value(self.target_obj, context, DoesNotDefined)
            target = MenuItem(target_rule, target_obj)

        if current is DoesNotDefined:
            keys = []
        else:
            keys = [(ancestor.name, ancestor.object)
                for ancestor in current.ancestors_for_menu()]

        if self.mode == 'auto':
            lasy = (target.name, target.object) not in keys
        else:
            lasy = False
        if target.name is None and target.object is DoesNotDefined:
            lasy = False

        children = target.children(lasy)
        for child in children:
            if (child.name, child.object) in keys:
                child.active = True
            if current is not None and current is not DoesNotDefined and (child.name, child.object) == (current.name, current.object):
                child.current = True

        menuproxy_level = context.get('menuproxy_level', -1) + 1
        return render_to_string('menuproxy/%s_menu.html' % self.mode, {
            'children': children,
            'current': current,
            'target': target,
            'menuproxy_level': menuproxy_level,
        }, context_instance=template.RequestContext(context.get('request', HttpRequest())))
コード例 #3
0
    def render(self, context):
        between_char = get_value(self.between_char, context)
        
        if 'menuproxy_breadcrumbs' in context:
            current = None
            ancestors = context['menuproxy_breadcrumbs']
        else:
            current_rule = get_value(self.current_rule, context)
            current_obj = get_value(self.current_obj, context)
            if current_rule is None:
                current = None
                ancestors = []
            else:
                current = MenuItem(current_rule, current_obj)
                ancestors = current.ancestors()

        return render_to_string('menuproxy/breadcrumbs.html', {
            'current': current,
            'breadcrumbs': ancestors,
            'breadcrumb_between_char': between_char,
        }, context_instance=template.RequestContext(context.get('request', HttpRequest())))