Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

[QUAD] Enhancement: Add settings entity and widget for ftrack task status #6341

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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: 3 additions & 1 deletion openpype/settings/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
DeadlineUrlEnumEntity,
AnatomyTemplatesEnumEntity,
ShotgridUrlEnumEntity,
RoyalRenderRootEnumEntity
RoyalRenderRootEnumEntity,
FtrackTaskStatusesEnumEntity
)

from .list_entity import ListEntity
Expand Down Expand Up @@ -172,6 +173,7 @@
"DeadlineUrlEnumEntity",
"ShotgridUrlEnumEntity",
"RoyalRenderRootEnumEntity",
"FtrackTaskStatusesEnumEntity",
"AnatomyTemplatesEnumEntity",

"ListEntity",
Expand Down
56 changes: 56 additions & 0 deletions openpype/settings/entities/enum_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,62 @@ def _get_enum_values(self):
return enum_items_list, valid_keys


class FtrackTaskStatusesEnumEntity(DynamicEnumEntity):
schema_types = ["ftrack-task-statuses"]

def _item_initialization(self):
self.multiselection = False
self.valid_value_types = (STRING_TYPE,)
self.value_on_not_set = ""
self.enum_items = []
self.valid_keys = set()
self.placeholder = None

def _get_enum_values(self):
# Import here to avoid circular import
from openpype.pipeline.context_tools import _get_modules_manager

manager = _get_modules_manager()
ftrack_module = manager.modules_by_name["ftrack"]
if not ftrack_module.enabled:
return [], set()

try:
ftrack_session = ftrack_module.create_ftrack_session()
except Exception: # noqa
# Ftrack not available (could be if a developer is in "opdev" mode)
return [], set()

task_status_names = [status["name"] for status in ftrack_session.query("Status").all()]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (95 > 79 characters)

# Add custom status
task_status_names.append("__any__")
task_status_names.sort()

if not task_status_names:
return [], set()

valid_keys = set()
enum_items = []
for task_status_name in task_status_names:
enum_items.append({task_status_name: task_status_name})
valid_keys.add(task_status_name)

return enum_items, valid_keys

def _convert_value_for_current_state(self, source_value):

if source_value not in self.valid_keys:
# Take first item from enum items
for item in self.enum_items:
for key in item.keys():
source_value = key
break
return source_value

def set_override_state(self, *args, **kwargs):
super(FtrackTaskStatusesEnumEntity, self).set_override_state(*args, **kwargs)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (85 > 79 characters)



class AnatomyTemplatesEnumEntity(BaseEnumEntity):
schema_types = ["anatomy-templates-enum"]

Expand Down
Loading