Updates the link displaying template to use conditional link display, updated admin and sentry link to use conditional display, updated main and secondary navigation to use the generic navigation template

This commit is contained in:
Roberto Rosario
2011-05-04 00:25:34 -04:00
parent b5791e7fce
commit 9dce568ac2
4 changed files with 44 additions and 22 deletions

View File

@@ -11,12 +11,17 @@ from user_management import user_list
from main.conf.settings import SIDE_BAR_SEARCH
def is_superuser(context):
return context['request'].user.is_staff or context['request'].user.is_superuser
check_settings = {'text': _(u'settings'), 'view': 'check_settings', 'famfam': 'cog'}
statistics = {'text': _(u'statistics'), 'view': 'statistics', 'famfam': 'table'}
diagnostics = {'text': _(u'diagnostics'), 'view': 'diagnostics', 'famfam': 'pill'}
tools = {'text': _(u'tools'), 'view': 'tools_menu', 'famfam': 'wrench'}
admin_site = {'text': _(u'admin site'), 'url': '/admin', 'famfam': 'keyboard'}
sentry = {'text': _(u'sentry'), 'url': '/sentry', 'famfam': 'bug'}
admin_site = {'text': _(u'admin site'), 'url': '/admin', 'famfam': 'keyboard', 'condition': is_superuser}
sentry = {'text': _(u'sentry'), 'url': '/sentry', 'famfam': 'bug', 'condition': is_superuser}
__version_info__ = {
'major': 0,

View File

@@ -107,13 +107,6 @@
{% endif %}
{% endif %}
</li>
{% if user.is_staff or user.is_superuser %}
<li><a href="/admin">{% trans "Admin site" %}</a></li>
{% endif %}
{% if user.is_staff or user.is_superuser %}
<li><a href="{% url sentry %}">{% trans "Sentry" %}</a></li>
{% endif %}
{% get_setting "MIDDLEWARE_CLASSES" as middleware_classes %}
{% if "django.middleware.locale.LocaleMiddleware" in middleware_classes %}
@@ -135,7 +128,15 @@
{% block web_theme_main_navigation %}
{% main_navigation %}
{% for link in navigation_main_links %}
<li class="{% if link.first %}first {% endif %}{% if link.active %}active{% endif %}"><a href="{{ link.url }}">{{ link.text|capfirst }}{% if link.famfam %}<span class="famfam active famfam-{{ link.famfam|default:'link' }}"></span>{% endif %}</a></li>
{% with "true" as as_li %}
{% with "true" as hide_active_anchor %}
{% with "active" as li_class_active %}
{% with "first" as li_class_first %}
{% include "generic_subnavigation.html" %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endfor %}
{% endblock %}
@@ -145,7 +146,15 @@
<div class="secondary-navigation">
<ul class="wat-cf">
{% for link in navigation_secondary_links %}
<li class="{% if link.first %}first {% endif %}{% if link.active %}active{% endif %}"><a class="{{ link.class }}" href="{{ link.url }}">{{ link.text|capfirst }}{% if link.famfam %}<span class="famfam active famfam-{{ link.famfam|default:'link' }}"></span>{% endif %}</a></li>
{% with "true" as as_li %}
{% with "true" as hide_active_anchor %}
{% with "active" as li_class_active %}
{% with "first" as li_class_first %}
{% include "generic_subnavigation.html" %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endfor %}
</ul>
</div>

View File

@@ -1 +1 @@
<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 %}<span class="famfam active famfam-resultset_previous"></span>{% endif %}</a>{% if horizontal %}{% if not forloop.last %} | {% endif %}{% endif %}
<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 %}

View File

@@ -1,14 +1,22 @@
{% load permission_tags %}
{% load navigation_tags %}
{% if link.permissions %}
{% check_permissions request.user link.permissions.namespace link.permissions.permissions %}
{% with link.permissions.namespace as namespace %}
{% with link.permissions.permissions as permissions %}
{% with link.condition as condition %}
{% check_permissions request.user namespace permissions %}
{% if permission %}
{% if as_li %}<li>{% endif %}
{% include "generic_link_instance.html" %}
{% if as_li %}</li>{% endif %}
{% evaluate_link condition as conditional_display %}
{% if conditional_display %}
{% if as_li %}
<li class="{% if link.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 %}
{% endif %}
{% else %}
{% if as_li %}<li>{% endif %}
{% include "generic_link_instance.html" %}
{% if as_li %}</li>{% endif %}
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}