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 If not provided, path defaults to <app_name>/subnav.yaml
""" """
obj = context['object'] # TODO: 118n !!!!!!!!!!!!!!
if not path: # How to internationalize yaml files????
path = '%s/subnav.yaml' % obj.__class__._meta.app_label menu = None
yaml_filename = os.path.join(TEMPLATES_DIR, path) if 'object' in context:
menu = yaml.load(open(yaml_filename, 'r')) obj = context['object']
resolve_urls_inplace(menu, obj.pk) 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) return dict(menu=menu)

6
templates/base.html

@ -1,6 +1,4 @@
{% load i18n %} {% load i18n staticfiles sass_tags menus %}
{% load staticfiles %}
{% load sass_tags %}
<!DOCTYPE html> <!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <!--[if gt IE 8]><!-->
@ -125,7 +123,7 @@
</span> </span>
</a> </a>
</div> </div>
{% block sections_nav %}{% endblock %} {% block sections_nav %} {% subnav %} {% endblock sections_nav %}
</div> </div>
</header> </header>
{% endblock main_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 %} {% load i18n %}
{% if menu %}
<ul class="nav nav-pills navbar-right"> <ul class="nav nav-pills navbar-right">
{% for item in menu %} {% for item in menu %}
@ -18,3 +20,4 @@
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %}

7
templates/sessao/sessaoplenaria_detail.html

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

Loading…
Cancel
Save