Browse Source

Move subnav to base template

pull/202/head
Marcio Mazza 9 years ago
parent
commit
7943a1daa1
  1. 16
      base/templatetags/menus.py
  2. 6
      templates/base.html
  3. 6
      templates/comissoes/comissao_detail.html
  4. 3
      templates/menus/subnav.html
  5. 7
      templates/sessao/sessaoplenaria_detail.html

16
base/templatetags/menus.py

@ -15,12 +15,16 @@ def subnav(context, path=None):
If not provided, path defaults to <app_name>/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)

6
templates/base.html

@ -1,6 +1,4 @@
{% load i18n %}
{% load staticfiles %}
{% load sass_tags %}
{% load i18n staticfiles sass_tags menus %}
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
@ -125,7 +123,7 @@
</span>
</a>
</div>
{% block sections_nav %}{% endblock %}
{% block sections_nav %} {% subnav %} {% endblock sections_nav %}
</div>
</header>
{% endblock main_header %}

6
templates/comissoes/comissao_detail.html

@ -1,6 +0,0 @@
{% extends "crud/detail.html" %}
{% load menus %}
{% block sections_nav %}
{% subnav %}
{% endblock sections_nav %}

3
templates/menus/subnav.html

@ -1,4 +1,6 @@
{% load i18n %}
{% if menu %}
<ul class="nav nav-pills navbar-right">
{% for item in menu %}
@ -18,3 +20,4 @@
{% endfor %}
</ul>
{% endif %}

7
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 %}

Loading…
Cancel
Save