diff --git a/openpype/modules/kitsu/plugins/publish/integrate_kitsu_note.py b/openpype/modules/kitsu/plugins/publish/integrate_kitsu_note.py index 6fda32d85f..8e0037fcf7 100644 --- a/openpype/modules/kitsu/plugins/publish/integrate_kitsu_note.py +++ b/openpype/modules/kitsu/plugins/publish/integrate_kitsu_note.py @@ -15,6 +15,7 @@ class IntegrateKitsuNote(pyblish.api.ContextPlugin): set_status_note = False note_status_shortname = "wfa" status_conditions = list() + family_requirements = list() # comment settings custom_comment_template = { @@ -72,6 +73,56 @@ class IntegrateKitsuNote(pyblish.api.ContextPlugin): if self.set_status_note and allow_status_change: kitsu_status = gazu.task.get_task_status_by_short_name( self.note_status_shortname + families = set() + for instance in context: + if instance.data.get('publish'): + families.add(instance.data['family']) + + # Get note status, by default uses the task status for the note + # if it is not specified in the configuration + kitsu_task = context.data["kitsu_task"] + shortname = kitsu_task["task_status"]["short_name"].upper() + note_status = kitsu_task["task_status_id"] + if self.set_status_note and next( + ( + False + for status_except in self.status_exceptions + if shortname == status_except["short_name"].upper() + and status_except["condition"] == "equal" + or + shortname != status_except["short_name"].upper() + and status_except["condition"] == "not_equal" + ), + True, + ) and next( + ( + True + for family in families + if next( + ( + False + for family_req in self.family_requirements + if family_req['equality'] != 'equal' + and family_req['family'] == family + or + family_req['equality'] == 'not_equal' + and family_req['family'] == family + ), + True, + ) + ), + False, + ): + kitsu_status = gazu.task.get_task_status_by_short_name( + self.note_status_shortname + ) + if kitsu_status: + note_status = kitsu_status + self.log.info("Note Kitsu status: {}".format(note_status)) + else: + self.log.info( + "Cannot find {} status. The status will not be " + "changed!".format(self.note_status_shortname) ) if kitsu_status: note_status = kitsu_status diff --git a/openpype/settings/defaults/project_settings/kitsu.json b/openpype/settings/defaults/project_settings/kitsu.json index 0638450595..32c6c253c7 100644 --- a/openpype/settings/defaults/project_settings/kitsu.json +++ b/openpype/settings/defaults/project_settings/kitsu.json @@ -9,6 +9,7 @@ "set_status_note": false, "note_status_shortname": "wfa", "status_conditions": [], + "family_requirements": [], "custom_comment_template": { "enabled": false, "comment_template": "{comment}\n\n| | |\n|--|--|\n| version| `{version}` |\n| family | `{family}` |\n| name | `{name}` |" diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_kitsu.json b/openpype/settings/entities/schemas/projects_schema/schema_project_kitsu.json index ee309f63a7..c32a2cb5af 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_kitsu.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_kitsu.json @@ -79,6 +79,31 @@ }, "label": "Status shortname" }, + { + "type": "list", + "key": "family_requirements", + "label": "Family requirements", + "object_type": { + "type": "dict", + "key": "requirement_dict", + "children": [ + { + "type": "enum", + "key": "equality", + "label": "Equality", + "enum_items": [ + {"equal": "Equal"}, + {"not_equal": "Not equal"} + ] + }, + { + "type": "text", + "key": "family", + "label": "Family" + } + ] + } + }, { "type": "dict", "collapsible": true, @@ -102,6 +127,7 @@ "label": "Custom comment" } ] + } } ] }