Merged conditional display code from the navigation template into the navigation tag, added support for conditional disabling of links

This commit is contained in:
Roberto Rosario
2011-06-28 01:05:57 -04:00
parent bafda3f7ad
commit 69c354b116
4 changed files with 56 additions and 63 deletions
@@ -1 +1,5 @@
<a class="{{ link.class }}" href="{{ link.url }}">{% if link.famfam %}<span class="famfam active famfam-{{ link.famfam|default:'link' }}"></span>{% endif %}{{ link.text|capfirst }}{% if link.error %} - {{ link.error }}{% endif %}{% if link.active and not hide_active_anchor %}<span class="famfam active famfam-resultset_previous"></span>{% endif %}</a>{% if horizontal %}{% if not forloop.last %} | {% endif %}{% endif %}
{% if link.disabled %}
<a class="{{ link.class }}" href="#">{% if link.famfam %}<span class="famfam inactive famfam-{{ link.famfam|default:'link' }}"></span>{% endif %}{{ link.text|capfirst }}{% if link.error %} - {{ link.error }}{% endif %}{% if link.active and not hide_active_anchor %}<span class="famfam active famfam-resultset_previous"></span>{% endif %}</a>{% if horizontal %}{% if not forloop.last %} | {% endif %}{% endif %}
{% else %}
<a class="{{ link.class }}" href="{{ link.url }}">{% if link.famfam %}<span class="famfam active famfam-{{ link.famfam|default:'link' }}"></span>{% endif %}{{ link.text|capfirst }}{% if link.error %} - {{ link.error }}{% endif %}{% if link.active and not hide_active_anchor %}<span class="famfam active famfam-resultset_previous"></span>{% endif %}</a>{% if horizontal %}{% if not forloop.last %} | {% endif %}{% endif %}
{% endif %}
@@ -1,5 +1,7 @@
<span class="nowrap">
{% for link in object_navigation_links %}
{% include "generic_subnavigation.html" %}
{% empty %}
none
{% endfor %}
</span>
@@ -2,19 +2,16 @@
{% load navigation_tags %}
{% with link.permissions as permissions %}
{% with link.condition as condition %}
{% check_permissions request.user permissions %}
{% if permission %}
{% evaluate_link condition as conditional_display %}
{% if conditional_display %}
{% if as_li %}
<li class="{% if forloop.first and li_class_first %}{{ li_class_first}} {% endif %}{% if link.active and li_class_active %}{{ li_class_active }}{% endif %}">
{% endif %}
{% include "generic_link_instance.html" %}
{% if as_li %}</li>{% endif %}
{% if as_li %}
<li class="{% if forloop.first and li_class_first %}{{ li_class_first }} {% endif %}{% if link.active and li_class_active %}{{ li_class_active }}{% endif %}">
{% endif %}
{% include "generic_link_instance.html" %}
{% if as_li %}
</li>
{% endif %}
{% endif %}
{% endwith %}
{% endwith %}