From 97b9bbc4a9f328906da95a34eef08ed2c01201c8 Mon Sep 17 00:00:00 2001 From: clearml <> Date: Thu, 5 Dec 2024 22:32:28 +0200 Subject: [PATCH] Return created_in_version property in users.get_current_user --- apiserver/bll/user/__init__.py | 7 ++++++- apiserver/database/model/user.py | 1 + apiserver/schema/services/users.conf | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apiserver/bll/user/__init__.py b/apiserver/bll/user/__init__.py index f47221b..46a7f85 100644 --- a/apiserver/bll/user/__init__.py +++ b/apiserver/bll/user/__init__.py @@ -2,6 +2,7 @@ from datetime import datetime from apiserver.apierrors import errors from apiserver.apimodels.users import CreateRequest +from apiserver.config.info import get_version from apiserver.database.errors import translate_errors_context from apiserver.database.model.user import User @@ -14,7 +15,11 @@ class UserBLL: if user_id and User.objects(id=user_id).only("id"): raise errors.bad_request.UserIdExists(id=user_id) - user = User(**request.to_struct(), created=datetime.utcnow()) + user = User( + **request.to_struct(), + created=datetime.utcnow(), + created_in_version=get_version(), + ) user.save(force_insert=True) @staticmethod diff --git a/apiserver/database/model/user.py b/apiserver/database/model/user.py index 9281908..4728804 100644 --- a/apiserver/database/model/user.py +++ b/apiserver/database/model/user.py @@ -20,4 +20,5 @@ class User(DbModelMixin, Document): given_name = StringField(user_set_allowed=True) avatar = StringField() preferences = DynamicField(default="", exclude_by_default=True) + created_in_version = StringField() created = DateTimeField() diff --git a/apiserver/schema/services/users.conf b/apiserver/schema/services/users.conf index b8605bc..f4512ff 100644 --- a/apiserver/schema/services/users.conf +++ b/apiserver/schema/services/users.conf @@ -166,6 +166,14 @@ get_current_user { } } } + "2.31": ${get_current_user."2.26"} { + response.properties { + user.properties.created_in_version { + type: string + description: Server version at user creation time + } + } + } } get_all_ex {