mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
optimisation of validator and xml message
This commit is contained in:
parent
4c90065f43
commit
ecf144993f
2 changed files with 31 additions and 24 deletions
|
|
@ -3,19 +3,29 @@
|
|||
<error id="main">
|
||||
<title>Shot/Asset name</title>
|
||||
<description>
|
||||
## Invalid node context keys and values
|
||||
## Publishing to a different asset context
|
||||
|
||||
Following Node with name: \`{node_name}\`
|
||||
There are publish instances present which are publishing into a different asset than your current context.
|
||||
|
||||
Context keys and values: \`{correct_values}\`
|
||||
Usually this is not what you want but there can be cases where you might want to publish into another asset/shot or task.
|
||||
|
||||
Wrong keys and values: \`{wrong_values}\`.
|
||||
If that's the case you can disable the validation on the instance to ignore it.
|
||||
|
||||
### How to repair?
|
||||
Following Node with name is wrong: \`{node_name}\`
|
||||
|
||||
1. Either use Repair or Select button.
|
||||
2. If you chose Select then rename asset knob to correct name.
|
||||
3. Hit Reload button on the publisher.
|
||||
### Correct context keys and values:
|
||||
|
||||
\`{correct_values}\`
|
||||
|
||||
### Wrong keys and values:
|
||||
|
||||
\`{wrong_values}\`.
|
||||
|
||||
|
||||
## How to repair?
|
||||
|
||||
1. Use \"Repair\" button.
|
||||
2. Hit Reload button on the publisher.
|
||||
</description>
|
||||
</error>
|
||||
</root>
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ValidateCorrectAssetContext(
|
|||
if not self.is_active(instance.data):
|
||||
return
|
||||
|
||||
invalid_keys = self.get_invalid(instance, compute=True)
|
||||
invalid_keys = self.get_invalid(instance)
|
||||
|
||||
if not invalid_keys:
|
||||
return
|
||||
|
|
@ -81,27 +81,24 @@ class ValidateCorrectAssetContext(
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance, compute=False):
|
||||
def get_invalid(cls, instance):
|
||||
"""Get invalid keys from instance data and context data."""
|
||||
invalid = instance.data.get("invalid_keys", [])
|
||||
|
||||
if compute:
|
||||
testing_keys = ["asset", "task"]
|
||||
for _key in testing_keys:
|
||||
if _key not in instance.data:
|
||||
invalid.append(_key)
|
||||
continue
|
||||
if instance.data[_key] != instance.context.data[_key]:
|
||||
invalid.append(_key)
|
||||
invalid_keys = []
|
||||
testing_keys = ["asset", "task"]
|
||||
for _key in testing_keys:
|
||||
if _key not in instance.data:
|
||||
invalid_keys.append(_key)
|
||||
continue
|
||||
if instance.data[_key] != instance.context.data[_key]:
|
||||
invalid_keys.append(_key)
|
||||
|
||||
instance.data["invalid_keys"] = invalid
|
||||
|
||||
return invalid
|
||||
return invalid_keys
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
"""Repair instance data with context data."""
|
||||
invalid = cls.get_invalid(instance)
|
||||
invalid_keys = cls.get_invalid(instance)
|
||||
|
||||
create_context = instance.context.data["create_context"]
|
||||
|
||||
|
|
@ -109,7 +106,7 @@ class ValidateCorrectAssetContext(
|
|||
created_instance = create_context.get_instance_by_id(
|
||||
instance_id
|
||||
)
|
||||
for _key in invalid:
|
||||
for _key in invalid_keys:
|
||||
created_instance[_key] = instance.context.data[_key]
|
||||
|
||||
create_context.save_changes()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue