Enhancement kitsu note with exceptions (#4537)

* Enhancement: Allowing kitsu not status exceptions

* Update openpype/modules/kitsu/plugins/publish/integrate_kitsu_note.py

Co-authored-by: Félix David <felixg.david@gmail.com>

* adding equal/not equal option

* Making equal/not equal option available at for every list item

* Changed  into , renamed  into , added documentation

* Using upper cases during check, so the new settings aren't case sensitive

* Linting little detail

* Renaming Equality into Condition, new screenshot with both equal and not equal shown on it

* Update website/docs/module_kitsu.md

README adjustments

Co-authored-by: Félix David <felixg.david@gmail.com>

* Changes needed to resolve conflict

* Changing context into instance where appropriate

* Minor change to avoid changing a line that doesn't need to be changed

* Turning exceptions into conditions. Making checks positive instead of negative. Changing implementation based on suggestions.

---------

Co-authored-by: Félix David <felixg.david@gmail.com>
This commit is contained in:
Sharkitty 2023-03-21 14:22:23 +00:00 committed by GitHub
parent ec9b6cb56d
commit 6f16f3e4f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 5 deletions

View file

@ -14,6 +14,7 @@ class IntegrateKitsuNote(pyblish.api.ContextPlugin):
# status settings
set_status_note = False
note_status_shortname = "wfa"
status_conditions = list()
# comment settings
custom_comment_template = {
@ -56,9 +57,19 @@ class IntegrateKitsuNote(pyblish.api.ContextPlugin):
# Get note status, by default uses the task status for the note
# if it is not specified in the configuration
note_status = kitsu_task["task_status"]["id"]
shortname = kitsu_task["task_status"]["short_name"].upper()
note_status = kitsu_task["task_status_id"]
if self.set_status_note:
# Check if any status condition is not met
allow_status_change = True
for status_cond in self.status_conditions:
condition = status_cond["condition"] == "equal"
match = status_cond["short_name"].upper() == shortname
if match and not condition or condition and not match:
allow_status_change = False
break
if self.set_status_note and allow_status_change:
kitsu_status = gazu.task.get_task_status_by_short_name(
self.note_status_shortname
)
@ -82,10 +93,11 @@ class IntegrateKitsuNote(pyblish.api.ContextPlugin):
self.log.debug("Comment is `{}`".format(publish_comment))
# Add comment to kitsu task
task_id = kitsu_task["id"]
self.log.debug("Add new note in taks id {}".format(task_id))
self.log.debug(
"Add new note in tasks id {}".format(kitsu_task["id"])
)
kitsu_comment = gazu.task.add_comment(
task_id, note_status, comment=publish_comment
kitsu_task, note_status, comment=publish_comment
)
instance.data["kitsu_comment"] = kitsu_comment

View file

@ -8,6 +8,7 @@
"IntegrateKitsuNote": {
"set_status_note": false,
"note_status_shortname": "wfa",
"status_conditions": [],
"custom_comment_template": {
"enabled": false,
"comment_template": "{comment}\n\n| | |\n|--|--|\n| version| `{version}` |\n| family | `{family}` |\n| name | `{name}` |"

View file

@ -51,6 +51,32 @@
{
"type": "text",
"key": "note_status_shortname",
"label": "Note shortname"
},
{
"type": "list",
"key": "status_conditions",
"label": "Status conditions",
"object_type": {
"type": "dict",
"key": "conditions_dict",
"children": [
{
"type": "enum",
"key": "condition",
"label": "Condition",
"enum_items": [
{"equal": "Equal"},
{"not_equal": "Not equal"}
]
},
{
"type": "text",
"key": "short_name",
"label": "Short name"
}
]
},
"label": "Status shortname"
},
{