mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge pull request #1009 from ynput/bugfix/create-instance-data
Create: Required keys in Create Instance data
This commit is contained in:
commit
ed06d0fd79
2 changed files with 14 additions and 2 deletions
|
|
@ -429,11 +429,18 @@ class CreatedInstance:
|
||||||
__immutable_keys = (
|
__immutable_keys = (
|
||||||
"id",
|
"id",
|
||||||
"instance_id",
|
"instance_id",
|
||||||
"product_type",
|
"productType",
|
||||||
"creator_identifier",
|
"creator_identifier",
|
||||||
"creator_attributes",
|
"creator_attributes",
|
||||||
"publish_attributes"
|
"publish_attributes"
|
||||||
)
|
)
|
||||||
|
# Keys that can be changed, but should not be removed from instance
|
||||||
|
__required_keys = {
|
||||||
|
"folderPath": None,
|
||||||
|
"task": None,
|
||||||
|
"productName": None,
|
||||||
|
"active": True,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
@ -515,6 +522,9 @@ class CreatedInstance:
|
||||||
if data:
|
if data:
|
||||||
self._data.update(data)
|
self._data.update(data)
|
||||||
|
|
||||||
|
for key, default in self.__required_keys.items():
|
||||||
|
self._data.setdefault(key, default)
|
||||||
|
|
||||||
if not self._data.get("instance_id"):
|
if not self._data.get("instance_id"):
|
||||||
self._data["instance_id"] = str(uuid4())
|
self._data["instance_id"] = str(uuid4())
|
||||||
|
|
||||||
|
|
@ -567,6 +577,8 @@ class CreatedInstance:
|
||||||
has_key = key in self._data
|
has_key = key in self._data
|
||||||
output = self._data.pop(key, *args, **kwargs)
|
output = self._data.pop(key, *args, **kwargs)
|
||||||
if has_key:
|
if has_key:
|
||||||
|
if key in self.__required_keys:
|
||||||
|
self._data[key] = self.__required_keys[key]
|
||||||
self._create_context.instance_values_changed(
|
self._create_context.instance_values_changed(
|
||||||
self.id, {key: None}
|
self.id, {key: None}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ class InstanceItem:
|
||||||
return InstanceItem(
|
return InstanceItem(
|
||||||
instance.id,
|
instance.id,
|
||||||
instance.creator_identifier,
|
instance.creator_identifier,
|
||||||
instance.label,
|
instance.label or "N/A",
|
||||||
instance.group_label,
|
instance.group_label,
|
||||||
instance.product_type,
|
instance.product_type,
|
||||||
instance.product_name,
|
instance.product_name,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue