diff --git a/mayan/apps/appearance/templates/appearance/base.html b/mayan/apps/appearance/templates/appearance/base.html index 48f9a3f09f..a4ce1daf29 100644 --- a/mayan/apps/appearance/templates/appearance/base.html +++ b/mayan/apps/appearance/templates/appearance/base.html @@ -101,18 +101,20 @@ @@ -182,15 +184,15 @@ {% if form_navigation_links %}
{% if form_navigation_links %} - {% with form_navigation_links as object_navigation_links %} - {% with 'true' as hide_active_anchor %} - {% with 'active' as link_class_active %} - {% with 'list-group-item btn-sm' as link_classes %} - {% include 'navigation/generic_navigation.html' %} - {% endwith %} - {% endwith %} - {% endwith %} - {% endwith %} + {% for object_navigation_links in form_navigation_links %} + {% with 'true' as hide_active_anchor %} + {% with 'active' as link_class_active %} + {% with 'list-group-item btn-sm' as link_classes %} + {% include 'navigation/generic_navigation.html' %} + {% endwith %} + {% endwith %} + {% endwith %} + {% endfor %} {% endif %}
{% endif %} diff --git a/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html b/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html index 6509ba9637..34527c7a36 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html @@ -13,7 +13,9 @@
{% with 'navigation/large_button_link.html' as link_template %} - {% include 'navigation/generic_navigation.html' %} + {% for object_navigation_links in resolved_links %} + {% include 'navigation/generic_navigation.html' %} + {% endfor %} {% endwith %}
diff --git a/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html b/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html index 30576179a5..1982e10db0 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html @@ -51,7 +51,7 @@ {% trans 'Identifier' %} {% endif %} - {% for column in object_list.0|get_model_list_columns %} + {% for column in object_list|get_model_list_columns %} {{ column.name }} {% endfor %} @@ -101,17 +101,17 @@ {% endfor %} {% if not hide_links %} - {% get_menu_links 'object menu' source=object as links %} - {% with links as object_navigation_links %} - {% with 'true' as horizontal %} - {% include 'navigation/generic_navigation.html' %} - {% endwith %} - {% endwith %} + {% get_menu_links 'object menu' source=object as resolved_links %} + {% for object_navigation_links in resolved_links %} + {% with 'true' as horizontal %} + {% include 'navigation/generic_navigation.html' %} + {% endwith %} + {% endfor %} {% endif %} {% empty %} - {% trans 'No results' %} + {% trans 'No results' %} {% endfor %} diff --git a/mayan/apps/appearance/templates/appearance/home.html b/mayan/apps/appearance/templates/appearance/home.html index f6f128da7b..fe62f73bac 100644 --- a/mayan/apps/appearance/templates/appearance/home.html +++ b/mayan/apps/appearance/templates/appearance/home.html @@ -38,10 +38,12 @@
- {% get_menu_links 'front page menu' as object_navigation_links %} + {% get_menu_links 'front page menu' as resolved_links %} {% with 'navigation/large_button_link.html' as link_template %} {% with 'col-xs-12 col-sm-6 col-md-4 col-lg-4' as div_class %} - {% include 'navigation/generic_navigation.html' %} + {% for object_navigation_links in resolved_links %} + {% include 'navigation/generic_navigation.html' %} + {% endfor %} {% endwith %} {% endwith %}
diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index 91199322b7..d7165420bb 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -459,7 +459,7 @@ class SetupListView(TemplateView): def get_context_data(self, **kwargs): data = super(SetupListView, self).get_context_data(**kwargs) data.update({ - 'object_navigation_links': menu_setup.resolve(context=RequestContext(self.request)), + 'resolved_links': menu_setup.resolve(context=RequestContext(self.request)), 'title': _('Setup items'), }) return data @@ -471,7 +471,7 @@ class ToolsListView(TemplateView): def get_context_data(self, **kwargs): data = super(ToolsListView, self).get_context_data(**kwargs) data.update({ - 'object_navigation_links': menu_tools.resolve(context=RequestContext(self.request)), + 'resolved_links': menu_tools.resolve(context=RequestContext(self.request)), 'title': _('Tools'), }) return data diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index 86a6c4deb5..d0f6a502e5 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -86,29 +86,43 @@ class Menu(object): pass for resolved_navigation_object in resolved_navigation_object_list: - for source, links in self.bound_links.iteritems(): + resolved_links = [] + + for bound_source, links in self.bound_links.iteritems(): try: - if inspect.isclass(source) and isinstance(resolved_navigation_object, source) or source == CombinedSource(obj=resolved_navigation_object.__class__, view=current_view): + if inspect.isclass(bound_source) and isinstance(resolved_navigation_object, bound_source) or source == CombinedSource(obj=resolved_navigation_object.__class__, view=current_view): for link in links: resolved_link = link.resolve(context=context, resolved_object=resolved_navigation_object) if resolved_link: - result.append(resolved_link) + resolved_links.append(resolved_link) break # No need for further content object match testing except TypeError: # When source is a dictionary pass + if resolved_links: + result.append(resolved_links) + + resolved_links = [] # View links for link in self.bound_links.get(current_view, []): resolved_link = link.resolve(context) if resolved_link: - result.append(resolved_link) + resolved_links.append(resolved_link) + + if resolved_links: + result.append(resolved_links) + + resolved_links = [] # Main menu links for link in self.bound_links.get(None, []): resolved_link = link.resolve(context) if resolved_link: - result.append(resolved_link) + resolved_links.append(resolved_link) + + if resolved_links: + result.append(resolved_links) return result diff --git a/mayan/apps/navigation/templatetags/navigation_tags.py b/mayan/apps/navigation/templatetags/navigation_tags.py index e88070b67f..391fe399bb 100644 --- a/mayan/apps/navigation/templatetags/navigation_tags.py +++ b/mayan/apps/navigation/templatetags/navigation_tags.py @@ -20,16 +20,20 @@ def get_menus_links(context, names, source=None): result = [] for name in names.split(','): - links = Menu.get(name=name).resolve(context) - if links: - result.append(links) + for links in Menu.get(name=name).resolve(context): + if links: + result.append(links) return result @register.simple_tag(takes_context=True) def get_multi_item_links_form(context, object_list): - actions = [(link.url, link.text) for link in Menu.get('multi item menu').resolve(context=context, source=object_list[0])] + actions = [] + for link_set in Menu.get('multi item menu').resolve(context=context, source=object_list[0]): + for link in link_set: + actions.append((link.url, link.text)) + form = MultiItemForm(actions=actions) context.update({'multi_item_form': form, 'multi_item_actions': actions}) return ''