Enhancement: Adding family requirements option to kitsu note

This commit is contained in:
Sharkitty 2023-03-01 14:41:51 +01:00
parent 96e184c8ca
commit c42ce4e96c
3 changed files with 78 additions and 0 deletions

View file

@ -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

View file

@ -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}` |"

View file

@ -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"
}
]
}
}
]
}