diff --git a/apps/main/__init__.py b/apps/main/__init__.py index 2c7b9dd077..2b8325ae86 100644 --- a/apps/main/__init__.py +++ b/apps/main/__init__.py @@ -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, diff --git a/apps/main/templates/base.html b/apps/main/templates/base.html index ab16999113..8e0a99eb18 100644 --- a/apps/main/templates/base.html +++ b/apps/main/templates/base.html @@ -107,13 +107,6 @@ {% endif %} {% endif %} - {% if user.is_staff or user.is_superuser %} -
  • {% trans "Admin site" %}
  • - {% endif %} - - {% if user.is_staff or user.is_superuser %} -
  • {% trans "Sentry" %}
  • - {% 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 %} -
  • {{ link.text|capfirst }}{% if link.famfam %}{% endif %}
  • + {% 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 @@
    diff --git a/apps/navigation/templates/generic_link_instance.html b/apps/navigation/templates/generic_link_instance.html index 380cb9da14..42cbf4916b 100644 --- a/apps/navigation/templates/generic_link_instance.html +++ b/apps/navigation/templates/generic_link_instance.html @@ -1 +1 @@ -{% if link.famfam %}{% endif %}{{ link.text|capfirst }}{% if link.error %} - {{ link.error }}{% endif %}{% if link.active %}{% endif %}{% if horizontal %}{% if not forloop.last %} | {% endif %}{% endif %} +{% if link.famfam %}{% endif %}{{ link.text|capfirst }}{% if link.error %} - {{ link.error }}{% endif %}{% if link.active and not hide_active_anchor %}{% endif %}{% if horizontal %}{% if not forloop.last %} | {% endif %}{% endif %} diff --git a/apps/navigation/templates/generic_subnavigation.html b/apps/navigation/templates/generic_subnavigation.html index 9e1863fa01..8585293bf6 100644 --- a/apps/navigation/templates/generic_subnavigation.html +++ b/apps/navigation/templates/generic_subnavigation.html @@ -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 %}
  • {% endif %} - {% include "generic_link_instance.html" %} - {% if as_li %}
  • {% endif %} + {% evaluate_link condition as conditional_display %} + {% if conditional_display %} + {% if as_li %} +
  • + {% endif %} + {% include "generic_link_instance.html" %} + {% if as_li %}
  • {% endif %} + {% endif %} {% endif %} -{% else %} - {% if as_li %}
  • {% endif %} - {% include "generic_link_instance.html" %} - {% if as_li %}
  • {% endif %} -{% endif %} + +{% endwith %} +{% endwith %} +{% endwith %}