AY-5539 - added project settings to CreatorContext

This commit is contained in:
Petr Kalis 2024-05-29 14:13:49 +02:00
parent 719e5aa56b
commit 3c287e1d64
2 changed files with 31 additions and 5 deletions

View file

@ -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.

View file

@ -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"]