lib: remove templatetags
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
94a5a6c4c0
commit
eeb9449c11
|
@ -20,7 +20,6 @@ from authentik.core.api.utils import (
|
|||
)
|
||||
from authentik.core.expression import PropertyMappingEvaluator
|
||||
from authentik.core.models import PropertyMapping
|
||||
from authentik.lib.templatetags.authentik_utils import verbose_name
|
||||
from authentik.lib.utils.reflection import all_subclasses
|
||||
from authentik.managed.api import ManagedSerializer
|
||||
from authentik.policies.api.exec import PolicyTestSerializer
|
||||
|
@ -87,9 +86,10 @@ class PropertyMappingViewSet(
|
|||
"""Get all creatable property-mapping types"""
|
||||
data = []
|
||||
for subclass in all_subclasses(self.queryset.model):
|
||||
subclass: PropertyMapping
|
||||
data.append(
|
||||
{
|
||||
"name": verbose_name(subclass),
|
||||
"name": subclass._meta.verbose_name,
|
||||
"description": subclass.__doc__,
|
||||
"component": subclass.component,
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ from rest_framework.viewsets import GenericViewSet
|
|||
|
||||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
||||
from authentik.core.models import Provider
|
||||
from authentik.lib.templatetags.authentik_utils import verbose_name
|
||||
from authentik.lib.utils.reflection import all_subclasses
|
||||
|
||||
|
||||
|
@ -73,9 +72,10 @@ class ProviderViewSet(
|
|||
"""Get all creatable provider types"""
|
||||
data = []
|
||||
for subclass in all_subclasses(self.queryset.model):
|
||||
subclass: Provider
|
||||
data.append(
|
||||
{
|
||||
"name": verbose_name(subclass),
|
||||
"name": subclass._meta.verbose_name,
|
||||
"description": subclass.__doc__,
|
||||
"component": subclass().component,
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ from structlog.stdlib import get_logger
|
|||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
||||
from authentik.core.models import Source
|
||||
from authentik.core.types import UserSettingSerializer
|
||||
from authentik.lib.templatetags.authentik_utils import verbose_name
|
||||
from authentik.lib.utils.reflection import all_subclasses
|
||||
from authentik.policies.engine import PolicyEngine
|
||||
|
||||
|
@ -67,9 +66,11 @@ class SourceViewSet(
|
|||
"""Get all creatable source types"""
|
||||
data = []
|
||||
for subclass in all_subclasses(self.queryset.model):
|
||||
subclass: Source
|
||||
# pyright: reportGeneralTypeIssues=false
|
||||
data.append(
|
||||
{
|
||||
"name": verbose_name(subclass),
|
||||
"name": subclass._meta.verbose_name,
|
||||
"description": subclass.__doc__,
|
||||
"component": subclass().component,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load authentik_utils %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{% extends 'base/skeleton.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load authentik_utils %}
|
||||
|
||||
{% block head %}
|
||||
{{ block.super }}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load authentik_utils %}
|
||||
|
||||
{% block body %}
|
||||
<div class="pf-c-background-image">
|
||||
|
|
|
@ -14,7 +14,6 @@ from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
|||
from authentik.core.types import UserSettingSerializer
|
||||
from authentik.flows.api.flows import FlowSerializer
|
||||
from authentik.flows.models import Stage
|
||||
from authentik.lib.templatetags.authentik_utils import verbose_name
|
||||
from authentik.lib.utils.reflection import all_subclasses
|
||||
|
||||
LOGGER = get_logger()
|
||||
|
@ -68,9 +67,10 @@ class StageViewSet(
|
|||
"""Get all creatable stage types"""
|
||||
data = []
|
||||
for subclass in all_subclasses(self.queryset.model, False):
|
||||
subclass: Stage
|
||||
data.append(
|
||||
{
|
||||
"name": verbose_name(subclass),
|
||||
"name": subclass._meta.verbose_name,
|
||||
"description": subclass.__doc__,
|
||||
"component": subclass().component,
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
"""authentik lib Templatetags"""
|
||||
|
||||
from django import template
|
||||
from django.db.models import Model
|
||||
from structlog.stdlib import get_logger
|
||||
|
||||
register = template.Library()
|
||||
LOGGER = get_logger()
|
||||
|
||||
|
||||
@register.filter("fieldtype")
|
||||
def fieldtype(field):
|
||||
"""Return classname"""
|
||||
if isinstance(field.__class__, Model) or issubclass(field.__class__, Model):
|
||||
return verbose_name(field)
|
||||
return field.__class__.__name__
|
||||
|
||||
|
||||
@register.filter(name="css_class")
|
||||
def css_class(field, css):
|
||||
"""Add css class to form field"""
|
||||
return field.as_widget(attrs={"class": css})
|
||||
|
||||
|
||||
@register.filter
|
||||
def verbose_name(obj) -> str:
|
||||
"""Return Object's Verbose Name"""
|
||||
if not obj:
|
||||
return ""
|
||||
if hasattr(obj, "verbose_name"):
|
||||
return obj.verbose_name
|
||||
return obj._meta.verbose_name
|
||||
|
||||
|
||||
@register.filter
|
||||
def form_verbose_name(obj) -> str:
|
||||
"""Return ModelForm's Object's Verbose Name"""
|
||||
if not obj:
|
||||
return ""
|
||||
return verbose_name(obj._meta.model)
|
|
@ -19,7 +19,6 @@ from authentik.core.api.utils import (
|
|||
PassiveSerializer,
|
||||
TypeCreateSerializer,
|
||||
)
|
||||
from authentik.lib.templatetags.authentik_utils import verbose_name
|
||||
from authentik.lib.utils.reflection import all_subclasses
|
||||
from authentik.outposts.models import (
|
||||
DockerServiceConnection,
|
||||
|
@ -76,9 +75,11 @@ class ServiceConnectionViewSet(
|
|||
"""Get all creatable service connection types"""
|
||||
data = []
|
||||
for subclass in all_subclasses(self.queryset.model):
|
||||
subclass: OutpostServiceConnection
|
||||
# pyright: reportGeneralTypeIssues=false
|
||||
data.append(
|
||||
{
|
||||
"name": verbose_name(subclass),
|
||||
"name": subclass._meta.verbose_name,
|
||||
"description": subclass.__doc__,
|
||||
"component": subclass().component,
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ from authentik.core.api.utils import (
|
|||
MetaNameSerializer,
|
||||
TypeCreateSerializer,
|
||||
)
|
||||
from authentik.lib.templatetags.authentik_utils import verbose_name
|
||||
from authentik.lib.utils.reflection import all_subclasses
|
||||
from authentik.policies.api.exec import PolicyTestResultSerializer, PolicyTestSerializer
|
||||
from authentik.policies.models import Policy, PolicyBinding
|
||||
|
@ -100,9 +99,10 @@ class PolicyViewSet(
|
|||
"""Get all creatable policy types"""
|
||||
data = []
|
||||
for subclass in all_subclasses(self.queryset.model):
|
||||
subclass: Policy
|
||||
data.append(
|
||||
{
|
||||
"name": verbose_name(subclass),
|
||||
"name": subclass._meta.verbose_name,
|
||||
"description": subclass.__doc__,
|
||||
"component": subclass().component,
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load authentik_utils %}
|
||||
|
||||
{% block card_title %}
|
||||
{% trans 'Permission denied' %}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load authentik_utils %}
|
||||
|
||||
{% block head %}
|
||||
{{ block.super }}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "email/base.html" %}
|
||||
|
||||
{% load authentik_utils %}
|
||||
{% load i18n %}
|
||||
{% load humanize %}
|
||||
|
||||
|
|
Reference in New Issue