From 15fa7e965277ea41d405fde8e416342b6e2f0bb8 Mon Sep 17 00:00:00 2001 From: "Langhammer, Jens" Date: Mon, 7 Oct 2019 16:50:13 +0200 Subject: [PATCH] ui(minor): merge menus --- passbook/core/templates/overview/base.html | 199 +++++++++------------ passbook/lib/templatetags/is_active.py | 13 +- passbook/policies/struct.py | 1 + passbook/providers/saml/xml_render.py | 1 + 4 files changed, 95 insertions(+), 119 deletions(-) diff --git a/passbook/core/templates/overview/base.html b/passbook/core/templates/overview/base.html index 647153a6c..5b80a7f3f 100644 --- a/passbook/core/templates/overview/base.html +++ b/passbook/core/templates/overview/base.html @@ -65,122 +65,93 @@ {% trans 'Overview' %} - {% is_active_app 'passbook_admin' as is_admin %} {% if user.is_superuser %} -
  • - - - {% trans 'Administration' %} +
  • + + + {% trans 'System Status' %} + +
  • +
  • + + + {% trans 'Applications' %} + +
  • +
  • + + + {% trans 'Sources' %} + +
  • +
  • + + + {% trans 'Providers' %} + +
  • +
  • + + + {% trans 'Property Mappings' %} + +
  • +
  • + + + {% trans 'Factors' %} + +
  • +
  • + + + {% trans 'Policies' %} + +
  • +
  • + + + {% trans 'Invitations' %} + +
  • +
  • + + + {% trans 'Users' %} + +
  • +
  • + + + {% trans 'Groups' %} + +
  • +
  • + + + {% trans 'Audit Log' %} + +
  • +
  • + + + {% trans 'Django' %} + +
  • +
  • + + + {% trans 'Debug' %} -
  • {% endif %} diff --git a/passbook/lib/templatetags/is_active.py b/passbook/lib/templatetags/is_active.py index dc93c1dde..9a5ac4cd8 100644 --- a/passbook/lib/templatetags/is_active.py +++ b/passbook/lib/templatetags/is_active.py @@ -1,6 +1,5 @@ """passbook lib navbar Templatetag""" from django import template -from django.urls import reverse from structlog import get_logger register = template.Library() @@ -17,7 +16,7 @@ def is_active(context, *args, **kwargs): return '' for url in args: short_url = url.split(':')[1] if ':' in url else url - # Check if resolve_match matches + # Check if resolver_match matches if request.resolver_match.url_name.startswith(url) or \ request.resolver_match.url_name.startswith(short_url): # Monkeypatch app_name: urls from core have app_name == '' @@ -30,15 +29,19 @@ def is_active(context, *args, **kwargs): @register.simple_tag(takes_context=True) -def is_active_url(context, view, *args, **kwargs): +def is_active_url(context, view): """Return whether a navbar link is active or not.""" - matching_url = reverse(view, args=args, kwargs=kwargs) + # matching_url = reverse(view, args=args, kwargs=kwargs) request = context.get('request') + current_full_url = f"{request.resolver_match.app_name}:{request.resolver_match.url_name}" + if not request.resolver_match: return '' - if matching_url == request.path: + if current_full_url == view: return 'active' + # if matching_url == request.path: + # return 'active' return '' diff --git a/passbook/policies/struct.py b/passbook/policies/struct.py index 83add6e3d..4381031c7 100644 --- a/passbook/policies/struct.py +++ b/passbook/policies/struct.py @@ -1,5 +1,6 @@ """policy structs""" from __future__ import annotations + from typing import TYPE_CHECKING, List from django.http import HttpRequest diff --git a/passbook/providers/saml/xml_render.py b/passbook/providers/saml/xml_render.py index 460d60cca..986bc5cbd 100644 --- a/passbook/providers/saml/xml_render.py +++ b/passbook/providers/saml/xml_render.py @@ -1,5 +1,6 @@ """Functions for creating XML output.""" from __future__ import annotations + from typing import TYPE_CHECKING from structlog import get_logger