From 3c287e1d64151f76487a504e40eb4afb21b7f0a0 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 May 2024 14:13:49 +0200 Subject: [PATCH] AY-5539 - added project settings to CreatorContext --- client/ayon_core/pipeline/create/context.py | 18 ++++++++++++++++++ client/ayon_core/tools/publisher/control.py | 18 +++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 45846553a4..f29f2a12a0 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -1401,6 +1401,7 @@ class CreateContext: self._current_folder_path = None self._current_task_name = None self._current_workfile_path = None + self._current_project_settings = None self._current_project_anatomy = None @@ -1571,6 +1572,17 @@ class CreateContext: return self._current_task_name + def get_current_task_entity(self): + """Task name which was used as current context on context reset. + + Returns: + Union[str, None]: Task name. + """ + task_name = self.get_current_task_name() + if self._current_task_entity is None and task_name: + self._current_task_entity = get_current_task_entity() + return self._current_task_entity + def get_current_workfile_path(self): """Workfile path which was opened on context reset. @@ -1592,6 +1604,12 @@ class CreateContext: self._current_project_name) return self._current_project_anatomy + def get_current_project_settings(self): + if self._current_project_settings is None: + self._current_project_settings = get_project_settings( + self.get_current_project_name()) + return self._current_project_settings + @property def context_has_changed(self): """Host context has changed. diff --git a/client/ayon_core/tools/publisher/control.py b/client/ayon_core/tools/publisher/control.py index 76c647d37f..9b12b3c318 100644 --- a/client/ayon_core/tools/publisher/control.py +++ b/client/ayon_core/tools/publisher/control.py @@ -39,7 +39,6 @@ from ayon_core.pipeline.create.context import ( ) from ayon_core.pipeline.publish import get_publish_instance_label from ayon_core.tools.common_models import HierarchyModel -from ayon_core.settings import get_project_settings from ayon_core.lib.profiles_filtering import filter_profiles from ayon_core.pipeline.context_tools import get_current_task_entity @@ -1665,6 +1664,16 @@ class PublisherController(BasePublisherController): return self._create_context.get_current_task_name() + @property + def current_project_settings(self): + """Current project settings. + + Returns: + dict + """ + + return self._create_context.get_current_project_settings() + @property def host_context_has_changed(self): return self._create_context.context_has_changed @@ -1835,7 +1844,7 @@ class PublisherController(BasePublisherController): if current_task_entity: task_type = current_task_entity["taskType"] allowed_creator_identifiers = self._get_allowed_creator_identifiers( - self.project_name, + self.current_project_settings, self._create_context.host_name, self.current_task_name, task_type, @@ -1861,7 +1870,7 @@ class PublisherController(BasePublisherController): def _get_allowed_creator_identifiers( self, - project_name, + project_settings, host_name, task_name, task_type, @@ -1872,9 +1881,8 @@ class PublisherController(BasePublisherController): If no profile provided for current context, it shows all creators """ allowed_creator_identifiers = None - proj_settings = get_project_settings(project_name) filter_creator_profiles = ( - proj_settings + project_settings ["core"] ["tools"] ["creator"]