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

Commit

Permalink
Merge pull request #1606 from pypeclub/feature/1605-settings-task-typ…
Browse files Browse the repository at this point in the history
…es-enum-entity
  • Loading branch information
mkolar authored May 31, 2021
2 parents d7adcf6 + 4e53753 commit 4519aa0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openpype/settings/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
EnumEntity,
AppsEnumEntity,
ToolsEnumEntity,
TaskTypeEnumEntity,
ProvidersEnum
)

Expand Down Expand Up @@ -154,6 +155,7 @@
"EnumEntity",
"AppsEnumEntity",
"ToolsEnumEntity",
"TaskTypeEnumEntity",
"ProvidersEnum",

"ListEntity",
Expand Down
35 changes: 35 additions & 0 deletions openpype/settings/entities/enum_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,41 @@ def set_override_state(self, *args, **kwargs):
self._current_value = new_value


class TaskTypeEnumEntity(BaseEnumEntity):
schema_types = ["task-types-enum"]

def _item_initalization(self):
self.multiselection = True
self.value_on_not_set = []
self.enum_items = []
self.valid_keys = set()
self.valid_value_types = (list, )
self.placeholder = None

def _get_enum_values(self):
anatomy_entity = self.get_entity_from_path(
"project_settings/project_anatomy"
)

valid_keys = set()
enum_items = []
for task_type in anatomy_entity["tasks"].keys():
enum_items.append({task_type: task_type})
valid_keys.add(task_type)

return enum_items, valid_keys

def set_override_state(self, *args, **kwargs):
super(TaskTypeEnumEntity, self).set_override_state(*args, **kwargs)

self.enum_items, self.valid_keys = self._get_enum_values()
new_value = []
for key in self._current_value:
if key in self.valid_keys:
new_value.append(key)
self._current_value = new_value


class ProvidersEnum(BaseEnumEntity):
schema_types = ["providers-enum"]

Expand Down

0 comments on commit 4519aa0

Please sign in to comment.