Skip to content

Commit

Permalink
Merge pull request #774 from BigRoy/enhancement/workfile_templates_cr…
Browse files Browse the repository at this point in the history
…eator_placeholder_active

Workfile Template Builder: Allow Create Placeholder to define the 'active' state
  • Loading branch information
iLLiCiTiT authored Jul 15, 2024
2 parents 8be1027 + 05f6b0f commit e970394
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion client/ayon_core/pipeline/create/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,8 @@ def create(
variant,
folder_entity=None,
task_entity=None,
pre_create_data=None
pre_create_data=None,
active=None
):
"""Trigger create of plugins with standartized arguments.
Expand All @@ -2061,6 +2062,8 @@ def create(
of creation (possible context of created instance/s).
task_entity (Dict[str, Any]): Task entity.
pre_create_data (Dict[str, Any]): Pre-create attribute values.
active (Optional[bool]): Whether the created instance defaults
to be active or not.
Returns:
Any: Output of triggered creator's 'create' method.
Expand Down Expand Up @@ -2126,6 +2129,14 @@ def create(
"productType": creator.product_type,
"variant": variant
}
if active is not None:
if not isinstance(active, bool):
self.log.warning(
"CreateContext.create 'active' argument is not a bool. "
f"Converting {active} {type(active)} to bool.")
active = bool(active)
instance_data["active"] = active

return creator.create(
product_name,
instance_data,
Expand Down
14 changes: 13 additions & 1 deletion client/ayon_core/pipeline/workfile/workfile_template_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,16 @@ def get_create_plugin_options(self, options=None):
"\ncompiling of product name."
)
),
attribute_definitions.BoolDef(
"active",
label="Active",
default=options.get("active", True),
tooltip=(
"Active"
"\nDefines whether the created instance will default to "
"active or not."
)
),
attribute_definitions.UISeparatorDef(),
attribute_definitions.NumberDef(
"order",
Expand Down Expand Up @@ -1823,6 +1833,7 @@ def populate_create_placeholder(self, placeholder, pre_create_data=None):
legacy_create = self.builder.use_legacy_creators
creator_name = placeholder.data["creator"]
create_variant = placeholder.data["create_variant"]
active = placeholder.data.get("active")

creator_plugin = self.builder.get_creators_by_name()[creator_name]

Expand Down Expand Up @@ -1870,7 +1881,8 @@ def populate_create_placeholder(self, placeholder, pre_create_data=None):
create_variant,
folder_entity,
task_entity,
pre_create_data=pre_create_data
pre_create_data=pre_create_data,
active=active
)

except: # noqa: E722
Expand Down

0 comments on commit e970394

Please sign in to comment.