Blender Kitsu: Add option to create tasks during Submit New Shot #121

Merged
Nick Alberelli merged 3 commits from :fix/submit-new-shot into main 2023-07-19 16:57:16 +02:00
3 changed files with 17 additions and 5 deletions

View File

@ -132,7 +132,7 @@ This will import a metastrip.mp4 (1000 frame black video) file which is saved in
3.3 Type in the name of the new shot in the `Shot` field 3.3 Type in the name of the new shot in the `Shot` field
3.4 Execute the `Submit New Shot` operator in the `Push` Panel (Will warn you if the shot already exists on Kitsu) 3.4 Execute the `Submit New Shot` operator in the `Push` Panel (Will warn you if the shot already exists on Kitsu). This operator can optionally populate each 'Shot' with a task set to the project's default task status.
>**Note**: Most of the operator are selection sensitive. So you can do these operations for a batch of sequence strips. If you have nothing selected it will usually try to operate on all strips in the sequence editor. <br/> >**Note**: Most of the operator are selection sensitive. So you can do these operations for a batch of sequence strips. If you have nothing selected it will usually try to operate on all strips in the sequence editor. <br/>
![image info](/media/addons/blender_kitsu/sqe_init_selection.jpg) ![image info](/media/addons/blender_kitsu/sqe_init_selection.jpg)

View File

@ -152,6 +152,7 @@ class KITSU_OT_sqe_push_new_shot(bpy.types.Operator):
bl_description = "Creates a new shot for each selected sequence strip on server. Checks if shot already exists" bl_description = "Creates a new shot for each selected sequence strip on server. Checks if shot already exists"
confirm: bpy.props.BoolProperty(name="confirm") confirm: bpy.props.BoolProperty(name="confirm")
add_tasks: bpy.props.BoolProperty(name="Add Default Tasks")
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
@ -238,7 +239,7 @@ class KITSU_OT_sqe_push_new_shot(bpy.types.Operator):
opsdata.push_sequence_color(context, seq) opsdata.push_sequence_color(context, seq)
# Push update to shot. # Push update to shot.
shot = push.new_shot(strip, seq, project_active) shot = push.new_shot(strip, seq, project_active, add_tasks=self.add_tasks)
pull.shot_meta(strip, shot) pull.shot_meta(strip, shot)
succeeded.append(strip) succeeded.append(strip)
@ -307,6 +308,7 @@ class KITSU_OT_sqe_push_new_shot(bpy.types.Operator):
text="Submit %s to server. Will skip shots if they already exist" text="Submit %s to server. Will skip shots if they already exist"
% (noun.lower()), % (noun.lower()),
) )
col.prop(self, "add_tasks", text="Add Tasks with the default status to shot(s)")
class KITSU_OT_sqe_push_new_sequence(bpy.types.Operator): class KITSU_OT_sqe_push_new_sequence(bpy.types.Operator):

View File

@ -25,6 +25,7 @@ import bpy
from blender_kitsu import bkglobals from blender_kitsu import bkglobals
from blender_kitsu.types import Sequence, Project, Shot from blender_kitsu.types import Sequence, Project, Shot
from blender_kitsu.logger import LoggerFactory from blender_kitsu.logger import LoggerFactory
import gazu
logger = LoggerFactory.getLogger() logger = LoggerFactory.getLogger()
@ -60,9 +61,7 @@ def shot_meta(strip: bpy.types.Sequence, shot: Shot) -> None:
def new_shot( def new_shot(
strip: bpy.types.Sequence, strip: bpy.types.Sequence, sequence: Sequence, project: Project, add_tasks=False
sequence: Sequence,
project: Project,
) -> Shot: ) -> Shot:
frame_range = (strip.frame_final_start, strip.frame_final_end) frame_range = (strip.frame_final_start, strip.frame_final_end)
shot = project.create_shot( shot = project.create_shot(
@ -75,6 +74,10 @@ def new_shot(
"fps": bkglobals.FPS, "fps": bkglobals.FPS,
}, },
) )
if add_tasks:
create_intial_tasks(shot, project)
# Update description, no option to pass that on create. # Update description, no option to pass that on create.
if strip.kitsu.shot_description: if strip.kitsu.shot_description:
shot.description = strip.kitsu.shot_description shot.description = strip.kitsu.shot_description
@ -105,3 +108,10 @@ def delete_shot(strip: bpy.types.Sequence, shot: Shot) -> str:
) )
strip.kitsu.clear() strip.kitsu.clear()
return result return result
def create_intial_tasks(shot: Shot, project: Project):
shot_entity = gazu.shot.get_shot(shot.id)
for task_type in gazu.task.all_task_types_for_project(project.id):
if task_type["for_entity"] == "Shot":
gazu.task.new_task(shot_entity, task_type)