core: include parent group name

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-05 00:11:17 +01:00
parent e587c53e18
commit 4a89be3048
3 changed files with 9 additions and 3 deletions

View File

@ -2,8 +2,8 @@
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django_filters.filters import ModelMultipleChoiceFilter from django_filters.filters import ModelMultipleChoiceFilter
from django_filters.filterset import FilterSet from django_filters.filterset import FilterSet
from rest_framework.fields import CharField, JSONField from rest_framework.fields import CharField, JSONField, SerializerMethodField
from rest_framework.serializers import ListSerializer, ModelSerializer from rest_framework.serializers import ListSerializer, ModelSerializer, Serializer
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ModelViewSet
from rest_framework_guardian.filters import ObjectPermissionsFilter from rest_framework_guardian.filters import ObjectPermissionsFilter
@ -42,6 +42,7 @@ class GroupSerializer(ModelSerializer):
users_obj = ListSerializer( users_obj = ListSerializer(
child=GroupMemberSerializer(), read_only=True, source="users", required=False child=GroupMemberSerializer(), read_only=True, source="users", required=False
) )
parent_name = CharField(source="parent.name", read_only=True)
class Meta: class Meta:
@ -51,6 +52,7 @@ class GroupSerializer(ModelSerializer):
"name", "name",
"is_superuser", "is_superuser",
"parent", "parent",
"parent_name",
"users", "users",
"attributes", "attributes",
"users_obj", "users_obj",

View File

@ -21437,6 +21437,9 @@ components:
type: string type: string
format: uuid format: uuid
nullable: true nullable: true
parent_name:
type: string
readOnly: true
users: users:
type: array type: array
items: items:
@ -21452,6 +21455,7 @@ components:
required: required:
- name - name
- parent - parent
- parent_name
- pk - pk
- users - users
- users_obj - users_obj

View File

@ -78,7 +78,7 @@ export class GroupListPage extends TablePage<Group> {
row(item: Group): TemplateResult[] { row(item: Group): TemplateResult[] {
return [ return [
html`${item.name}`, html`${item.name}`,
html`${item.parent || t`-`}`, html`${item.parentName || t`-`}`,
html`${Array.from(item.users || []).length}`, html`${Array.from(item.users || []).length}`,
html`${item.isSuperuser ? t`Yes` : t`No`}`, html`${item.isSuperuser ? t`Yes` : t`No`}`,
html` <ak-forms-modal> html` <ak-forms-modal>