From 4a89be30483192ca41df832ce96237cee789b5ed Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 5 Nov 2021 00:11:17 +0100 Subject: [PATCH] core: include parent group name Signed-off-by: Jens Langhammer --- authentik/core/api/groups.py | 6 ++++-- schema.yml | 4 ++++ web/src/pages/groups/GroupListPage.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/authentik/core/api/groups.py b/authentik/core/api/groups.py index 90955215e..380e78a51 100644 --- a/authentik/core/api/groups.py +++ b/authentik/core/api/groups.py @@ -2,8 +2,8 @@ from django.db.models.query import QuerySet from django_filters.filters import ModelMultipleChoiceFilter from django_filters.filterset import FilterSet -from rest_framework.fields import CharField, JSONField -from rest_framework.serializers import ListSerializer, ModelSerializer +from rest_framework.fields import CharField, JSONField, SerializerMethodField +from rest_framework.serializers import ListSerializer, ModelSerializer, Serializer from rest_framework.viewsets import ModelViewSet from rest_framework_guardian.filters import ObjectPermissionsFilter @@ -42,6 +42,7 @@ class GroupSerializer(ModelSerializer): users_obj = ListSerializer( child=GroupMemberSerializer(), read_only=True, source="users", required=False ) + parent_name = CharField(source="parent.name", read_only=True) class Meta: @@ -51,6 +52,7 @@ class GroupSerializer(ModelSerializer): "name", "is_superuser", "parent", + "parent_name", "users", "attributes", "users_obj", diff --git a/schema.yml b/schema.yml index 42e213bc8..1d1cd67dc 100644 --- a/schema.yml +++ b/schema.yml @@ -21437,6 +21437,9 @@ components: type: string format: uuid nullable: true + parent_name: + type: string + readOnly: true users: type: array items: @@ -21452,6 +21455,7 @@ components: required: - name - parent + - parent_name - pk - users - users_obj diff --git a/web/src/pages/groups/GroupListPage.ts b/web/src/pages/groups/GroupListPage.ts index f70997065..d84984305 100644 --- a/web/src/pages/groups/GroupListPage.ts +++ b/web/src/pages/groups/GroupListPage.ts @@ -78,7 +78,7 @@ export class GroupListPage extends TablePage { row(item: Group): TemplateResult[] { return [ html`${item.name}`, - html`${item.parent || t`-`}`, + html`${item.parentName || t`-`}`, html`${Array.from(item.users || []).length}`, html`${item.isSuperuser ? t`Yes` : t`No`}`, html`