mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 14:22:37 +01:00
Merged in feature/PYPE-727_ftrack_comment_with_intent (pull request #501)
feature/PYPE-727_ftrack_comment_with_intent Approved-by: Milan Kolar <milan@orbi.tools>
This commit is contained in:
commit
716c0ba4fb
1 changed files with 35 additions and 2 deletions
|
|
@ -12,13 +12,32 @@ class IntegrateFtrackNote(pyblish.api.InstancePlugin):
|
|||
families = ["ftrack"]
|
||||
optional = True
|
||||
|
||||
# Can be set in presets:
|
||||
# - Allows only `intent` and `comment` keys
|
||||
note_with_intent_template = "{intent}: {comment}"
|
||||
# - note label must exist in Ftrack
|
||||
note_labels = []
|
||||
|
||||
def process(self, instance):
|
||||
comment = (instance.context.data.get("comment") or "").strip()
|
||||
if not comment:
|
||||
self.log.info("Comment is not set.")
|
||||
return
|
||||
|
||||
self.log.debug("Comment is set to {}".format(comment))
|
||||
self.log.debug("Comment is set to `{}`".format(comment))
|
||||
|
||||
intent = instance.context.data.get("intent")
|
||||
if intent:
|
||||
msg = "Intent is set to `{}` and was added to comment.".format(
|
||||
intent
|
||||
)
|
||||
comment = self.note_with_intent_template.format(**{
|
||||
"intent": intent,
|
||||
"comment": comment
|
||||
})
|
||||
else:
|
||||
msg = "Intent is not set."
|
||||
self.log.debug(msg)
|
||||
|
||||
asset_versions_key = "ftrackIntegratedAssetVersions"
|
||||
asset_versions = instance.data.get(asset_versions_key)
|
||||
|
|
@ -37,8 +56,22 @@ class IntegrateFtrackNote(pyblish.api.InstancePlugin):
|
|||
)
|
||||
)
|
||||
|
||||
labels = []
|
||||
if self.note_labels:
|
||||
all_labels = session.query("NoteLabel").all()
|
||||
labels_by_low_name = {lab["name"].lower(): lab for lab in all_labels}
|
||||
for _label in self.note_labels:
|
||||
label = labels_by_low_name.get(_label.lower())
|
||||
if not label:
|
||||
self.log.warning(
|
||||
"Note Label `{}` was not found.".format(_label)
|
||||
)
|
||||
continue
|
||||
|
||||
labels.append(label)
|
||||
|
||||
for asset_version in asset_versions:
|
||||
asset_version.create_note(comment, author=user)
|
||||
asset_version.create_note(comment, author=user, labels=labels)
|
||||
|
||||
try:
|
||||
session.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue