Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions label_studio/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ def get(self, request, *args, **kwargs):
name='get',
decorator=extend_schema(
tags=['Users'],
summary='Retrieve my user',
description='Retrieve details of the account that you are using to access the API.',
summary='Whoami for current user',
description='Make the whoami call on behalf of the user you are using to access the API.',
request=None,
responses={200: WhoAmIUserSerializer},
extensions={
Expand Down
13 changes: 11 additions & 2 deletions label_studio/users/serializers.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
"""This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
"""
from typing import TypedDict

from core.utils.common import load_func
from django.conf import settings
from rest_flex_fields import FlexFieldsModelSerializer
from rest_framework import serializers
from users.models import User


class ActiveOrganizationMeta(TypedDict):
title: str
email: str


class BaseUserSerializer(FlexFieldsModelSerializer):
# short form for user presentation
initials = serializers.SerializerMethodField(default='?', read_only=True)
avatar = serializers.SerializerMethodField(read_only=True)
active_organization_meta = serializers.SerializerMethodField(read_only=True)
active_organization_meta = serializers.SerializerMethodField(
help_text='Active organization metadata', read_only=True
)
last_activity = serializers.DateTimeField(read_only=True, source='last_activity_cached')

def get_avatar(self, instance):
Expand All @@ -20,7 +29,7 @@ def get_avatar(self, instance):
def get_initials(self, instance):
return instance.get_initials(self._is_deleted(instance))

def get_active_organization_meta(self, instance):
def get_active_organization_meta(self, instance) -> ActiveOrganizationMeta:
organization = instance.active_organization
if organization is None:
return {'title': '', 'email': ''}
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dependencies = [
"tldextract (>=5.1.3)",
"uuid-utils (>=0.11.0,<1.0.0)",
## HumanSignal repo dependencies :start
"label-studio-sdk @ https://github.com/HumanSignal/label-studio-sdk/archive/77b0c0abd2847c914096e6054b6f1b1805ee1b7a.zip",
"label-studio-sdk @ https://github.com/HumanSignal/label-studio-sdk/archive/bb1b70dea95d5829b57021070ce5ccdd7ed60e47.zip",
## HumanSignal repo dependencies :end
]

Expand Down
Loading