Corrected shipherd Navigation cache clearing and made grappelli attribute inline...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Tue, 11 Jan 2011 14:13:54 +0000 (09:13 -0500)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Tue, 11 Jan 2011 16:28:29 +0000 (11:28 -0500)
contrib/shipherd/models.py
contrib/shipherd/templatetags/shipherd.py
templates/admin/philo/edit_inline/grappelli_tabular_attribute.html

index e43e8d9..72bd775 100644 (file)
@@ -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:
index fec700b..8adef3e 100644 (file)
@@ -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:
                <ul>
-                       {% recursenavigation navigation %}
+                       {% recursenavigation node %}
                                <li{% if active %} class='active'{% endif %}>
-                                       {{ node.name }}
-                                       {% if not node.is_leaf_node %}
+                                       {{ navigation.text }}
+                                       {% if not navigation.is_leaf_node %}
                                                <ul>
                                                        {{ children }}
                                                </ul>
@@ -69,4 +69,9 @@ def recursenavigation(parser, token):
        template_nodes = parser.parse(('endrecursenavigation',))
        parser.delete_first_token()
        
-       return RecurseNavigationNode(template_nodes, instance_var)
\ No newline at end of file
+       return RecurseNavigationNode(template_nodes, instance_var)
+
+
+@register.filter
+def has_navigation(node):
+       return bool(Navigation.objects.closest_navigation(node).count())
\ No newline at end of file
index 4760397..ea95b2c 100644 (file)
@@ -3,7 +3,7 @@
 <!-- group -->
 <div class="group tabular{% if inline_admin_formset.opts.classes %} {{ inline_admin_formset.opts.classes|join:" " }}{% endif %}"
        id="{{ inline_admin_formset.formset.prefix }}-group" >
-       <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
+       <h2 class="collapse-handler">{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
        <ul class="tools">
                <li class="add-handler-container"><a href="javascript://" class="icon add-handler" title="{% trans 'Add Another' %}"> </a></li>
        </ul>