diff --git a/base/templatetags/menus.py b/base/templatetags/menus.py index 257b801ee..2c9f00fb9 100644 --- a/base/templatetags/menus.py +++ b/base/templatetags/menus.py @@ -15,12 +15,16 @@ def subnav(context, path=None): If not provided, path defaults to /subnav.yaml """ - obj = context['object'] - if not path: - path = '%s/subnav.yaml' % obj.__class__._meta.app_label - yaml_filename = os.path.join(TEMPLATES_DIR, path) - menu = yaml.load(open(yaml_filename, 'r')) - resolve_urls_inplace(menu, obj.pk) + # TODO: 118n !!!!!!!!!!!!!! + # How to internationalize yaml files???? + menu = None + if 'object' in context: + obj = context['object'] + default_path = '%s/subnav.yaml' % obj.__class__._meta.app_label + path = os.path.join(TEMPLATES_DIR, path or default_path) + if os.path.exists(path): + menu = yaml.load(open(path, 'r')) + resolve_urls_inplace(menu, obj.pk) return dict(menu=menu) diff --git a/templates/base.html b/templates/base.html index 3fd9b8a50..6c6b2f7fb 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,4 @@ -{% load i18n %} -{% load staticfiles %} -{% load sass_tags %} +{% load i18n staticfiles sass_tags menus %} @@ -125,7 +123,7 @@ - {% block sections_nav %}{% endblock %} + {% block sections_nav %} {% subnav %} {% endblock sections_nav %} {% endblock main_header %} diff --git a/templates/comissoes/comissao_detail.html b/templates/comissoes/comissao_detail.html deleted file mode 100644 index 46eb1fe85..000000000 --- a/templates/comissoes/comissao_detail.html +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "crud/detail.html" %} -{% load menus %} - -{% block sections_nav %} - {% subnav %} -{% endblock sections_nav %} diff --git a/templates/menus/subnav.html b/templates/menus/subnav.html index bb74daf48..85fdecb83 100644 --- a/templates/menus/subnav.html +++ b/templates/menus/subnav.html @@ -1,4 +1,6 @@ {% load i18n %} + +{% if menu %} +{% endif %} diff --git a/templates/sessao/sessaoplenaria_detail.html b/templates/sessao/sessaoplenaria_detail.html index 83ddd741c..1c03e9c25 100644 --- a/templates/sessao/sessaoplenaria_detail.html +++ b/templates/sessao/sessaoplenaria_detail.html @@ -1,7 +1,2 @@ {% extends "crud/detail.html" %} -{% load menus %} -{% block actions %} {% endblock %} - -{% block sections_nav %} - {% subnav %} -{% endblock sections_nav %} +{% block actions %}{% endblock %}