core: add settings serializer to user/me and update_self endpoints, saved in a key in attributes

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-09 15:35:18 +02:00
parent 50a623d8ab
commit b33ea9cc61
2 changed files with 11 additions and 1 deletions

View file

@ -22,7 +22,7 @@ from drf_spectacular.utils import (
) )
from guardian.shortcuts import get_anonymous_user, get_objects_for_user from guardian.shortcuts import get_anonymous_user, get_objects_for_user
from rest_framework.decorators import action from rest_framework.decorators import action
from rest_framework.fields import CharField, JSONField, SerializerMethodField from rest_framework.fields import CharField, DictField, JSONField, SerializerMethodField
from rest_framework.permissions import IsAuthenticated from rest_framework.permissions import IsAuthenticated
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response from rest_framework.response import Response
@ -103,6 +103,7 @@ class UserSelfSerializer(ModelSerializer):
avatar = CharField(read_only=True) avatar = CharField(read_only=True)
groups = SerializerMethodField() groups = SerializerMethodField()
uid = CharField(read_only=True) uid = CharField(read_only=True)
settings = DictField(source="attributes.settings")
@extend_schema_field( @extend_schema_field(
ListSerializer( ListSerializer(
@ -133,6 +134,7 @@ class UserSelfSerializer(ModelSerializer):
"email", "email",
"avatar", "avatar",
"uid", "uid",
"settings",
] ]
extra_kwargs = { extra_kwargs = {
"is_active": {"read_only": True}, "is_active": {"read_only": True},

View file

@ -29295,6 +29295,9 @@ components:
uid: uid:
type: string type: string
readOnly: true readOnly: true
settings:
type: object
additionalProperties: {}
required: required:
- avatar - avatar
- groups - groups
@ -29302,6 +29305,7 @@ components:
- is_superuser - is_superuser
- name - name
- pk - pk
- settings
- uid - uid
- username - username
UserSelfGroups: UserSelfGroups:
@ -29336,8 +29340,12 @@ components:
format: email format: email
title: Email address title: Email address
maxLength: 254 maxLength: 254
settings:
type: object
additionalProperties: {}
required: required:
- name - name
- settings
- username - username
UserServiceAccountRequest: UserServiceAccountRequest:
type: object type: object