From ef4e779e06153aa4d2378de4fb049c1b7e8f045d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 24 May 2024 17:53:31 +0200 Subject: [PATCH] fill createdBy and updateBy --- .../tools/workfiles/models/workfiles.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/workfiles/models/workfiles.py b/client/ayon_core/tools/workfiles/models/workfiles.py index 40b56ed99c..ca7654846b 100644 --- a/client/ayon_core/tools/workfiles/models/workfiles.py +++ b/client/ayon_core/tools/workfiles/models/workfiles.py @@ -6,6 +6,7 @@ import arrow import ayon_api from ayon_api.operations import OperationsSession +from ayon_core.lib import get_ayon_username from ayon_core.pipeline.template_data import ( get_template_data, get_task_template_data, @@ -23,6 +24,8 @@ from ayon_core.tools.workfiles.abstract import ( WorkfileInfo, ) +_NOT_SET = object() + class CommentMatcher(object): """Use anatomy and work file data to parse comments from filenames. @@ -445,6 +448,7 @@ class WorkfileEntitiesModel: self._controller = controller self._cache = {} self._items = {} + self._current_username = _NOT_SET def _get_workfile_info_identifier( self, folder_id, task_id, rootless_path @@ -563,13 +567,18 @@ class WorkfileEntitiesModel: project_name = self._controller.get_current_project_name() + username = self._get_current_username() workfile_info = { "path": rootless_path, "taskId": task_id, "attrib": { "extension": extension, "description": note - } + }, + # TODO remove 'createdBy' and 'updatedBy' fields when server is + # or above 1.1.3 . + "createdBy": username, + "updatedBy": username, } session = OperationsSession() @@ -577,6 +586,11 @@ class WorkfileEntitiesModel: session.commit() return workfile_info + def _get_current_username(self): + if self._current_username is _NOT_SET: + self._current_username = get_ayon_username() + return self._current_username + class PublishWorkfilesModel: """Model for handling of published workfiles.