From: Stephen Burrows Date: Tue, 11 Jan 2011 14:13:54 +0000 (-0500) Subject: Corrected shipherd Navigation cache clearing and made grappelli attribute inline... X-Git-Tag: philo-0.9~22^2~16 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/7838f389cf5ebed7c23b764581cd563d1865828c Corrected shipherd Navigation cache clearing and made grappelli attribute inline template compatible with grappelli r1399. Tweaked recursenavigation template tag behavior to set {{ navigation }} in the context instead of node and corrected its documentation. Added has_navigation filter. --- diff --git a/contrib/shipherd/models.py b/contrib/shipherd/models.py index e43e8d9..72bd775 100644 --- a/contrib/shipherd/models.py +++ b/contrib/shipherd/models.py @@ -111,7 +111,7 @@ class NavigationManager(TreeManager): """ if navigation is None: self.__class__._cache.clear() - else: + elif self.db in self.__class__._cache: cache = self.__class__._cache[self.db] for pk, qs in cache.items(): if navigation in qs: diff --git a/contrib/shipherd/templatetags/shipherd.py b/contrib/shipherd/templatetags/shipherd.py index fec700b..8adef3e 100644 --- a/contrib/shipherd/templatetags/shipherd.py +++ b/contrib/shipherd/templatetags/shipherd.py @@ -17,9 +17,9 @@ class RecurseNavigationNode(RecurseTreeNode): bits = [] context.push() for child in node.get_children(): - context['node'] = child + context['navigation'] = child bits.append(self._render_node(context, child, request)) - context['node'] = node + context['navigation'] = node context['children'] = mark_safe(u''.join(bits)) context['active'] = node.is_active(request) rendered = self.template_nodes.render(context) @@ -41,17 +41,17 @@ class RecurseNavigationNode(RecurseTreeNode): @register.tag def recursenavigation(parser, token): """ - Based on django-mptt's recursetree templatetag. In addition to {{ node }} and {{ children }}, + Based on django-mptt's recursetree templatetag. In addition to {{ navigation }} and {{ children }}, sets {{ active }} in the context. - Note that the tag takes one variable, navigation, which is a Navigation instance. + Note that the tag takes one variable, which is a Node instance. Usage: