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 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.request import Request
from rest_framework.response import Response
@ -103,6 +103,7 @@ class UserSelfSerializer(ModelSerializer):
avatar = CharField(read_only=True)
groups = SerializerMethodField()
uid = CharField(read_only=True)
settings = DictField(source="attributes.settings")
@extend_schema_field(
ListSerializer(
@ -133,6 +134,7 @@ class UserSelfSerializer(ModelSerializer):
"email",
"avatar",
"uid",
"settings",
]
extra_kwargs = {
"is_active": {"read_only": True},

View File

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