From f020b7938411e9a6d22801bec98e8ad5946c13bb Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 8 Feb 2021 19:07:25 +0100 Subject: [PATCH] admin: remove old code --- .../outpost_service_connection/list.html | 1 - .../templates/administration/source/list.html | 5 --- .../templates/administration/stage/list.html | 5 --- .../administration/stage_prompt/list.html | 5 --- authentik/admin/templatetags/__init__.py | 0 .../admin/templatetags/admin_reflection.py | 34 ------------------- 6 files changed, 50 deletions(-) delete mode 100644 authentik/admin/templatetags/__init__.py delete mode 100644 authentik/admin/templatetags/admin_reflection.py diff --git a/authentik/admin/templates/administration/outpost_service_connection/list.html b/authentik/admin/templates/administration/outpost_service_connection/list.html index 79cee25d0..b43dcf2dc 100644 --- a/authentik/admin/templates/administration/outpost_service_connection/list.html +++ b/authentik/admin/templates/administration/outpost_service_connection/list.html @@ -3,7 +3,6 @@ {% load i18n %} {% load humanize %} {% load authentik_utils %} -{% load admin_reflection %} {% block content %}
diff --git a/authentik/admin/templates/administration/source/list.html b/authentik/admin/templates/administration/source/list.html index f29089409..777a6ded2 100644 --- a/authentik/admin/templates/administration/source/list.html +++ b/authentik/admin/templates/administration/source/list.html @@ -2,7 +2,6 @@ {% load i18n %} {% load authentik_utils %} -{% load admin_reflection %} {% block content %}
@@ -93,10 +92,6 @@
- {% get_links source as links %} - {% for name, href in links %} - {% trans name %} - {% endfor %} {% endfor %} diff --git a/authentik/admin/templates/administration/stage/list.html b/authentik/admin/templates/administration/stage/list.html index 4fe3d48ff..def5e20ba 100644 --- a/authentik/admin/templates/administration/stage/list.html +++ b/authentik/admin/templates/administration/stage/list.html @@ -2,7 +2,6 @@ {% load i18n %} {% load authentik_utils %} -{% load admin_reflection %} {% block content %}
@@ -88,10 +87,6 @@
- {% get_links stage as links %} - {% for name, href in links.items %} - {% trans name %} - {% endfor %} {% endfor %} diff --git a/authentik/admin/templates/administration/stage_prompt/list.html b/authentik/admin/templates/administration/stage_prompt/list.html index 45ca2e5bc..41b435e68 100644 --- a/authentik/admin/templates/administration/stage_prompt/list.html +++ b/authentik/admin/templates/administration/stage_prompt/list.html @@ -2,7 +2,6 @@ {% load i18n %} {% load authentik_utils %} -{% load admin_reflection %} {% block content %}
@@ -90,10 +89,6 @@
- {% get_links prompt as links %} - {% for name, href in links.items %} - {% trans name %} - {% endfor %} {% endfor %} diff --git a/authentik/admin/templatetags/__init__.py b/authentik/admin/templatetags/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/authentik/admin/templatetags/admin_reflection.py b/authentik/admin/templatetags/admin_reflection.py deleted file mode 100644 index 848e9c1f8..000000000 --- a/authentik/admin/templatetags/admin_reflection.py +++ /dev/null @@ -1,34 +0,0 @@ -"""authentik admin templatetags""" -from django import template -from django.db.models import Model -from structlog.stdlib import get_logger - -register = template.Library() -LOGGER = get_logger() - - -@register.simple_tag() -def get_links(model_instance): - """Find all link_ methods on an object instance, run them and return as dict""" - prefix = "link_" - links = {} - - if not isinstance(model_instance, Model): - LOGGER.warning("Model is not instance of Model", model_instance=model_instance) - return links - - try: - for name in dir(model_instance): - if not name.startswith(prefix): - continue - value = getattr(model_instance, name) - if not callable(value): - continue - human_name = name.replace(prefix, "").replace("_", " ").capitalize() - link = value() - if link: - links[human_name] = link - except NotImplementedError: - pass - - return links