Add shot/asset typing and owned task types to departments
Departments now carry a type (shot or asset) and own a list of task types (e.g. Animation: blocking/primary_pass/second_pass, Composite: first_pass/second_pass, plus a new Simulation department), additive to the existing flat Custom Task Type system. When a task's type belongs to a department, its department is derived and kept in sync server-side across create/update paths; Task Type is now editable in the Task Detail panel and Department options are filtered to the task's shot/asset scope.
This commit is contained in:
+16
-10
@@ -13,6 +13,7 @@ from schemas.shot import (
|
||||
BulkShotCreate, BulkShotResponse, TaskStatusInfo
|
||||
)
|
||||
from utils.auth import get_current_user_from_token, require_permission
|
||||
from utils.departments import find_owning_department
|
||||
from services.shot_soft_deletion import ShotSoftDeletionService
|
||||
|
||||
router = APIRouter()
|
||||
@@ -131,26 +132,27 @@ def get_all_shot_task_types(project_id: int, db: Session) -> List[str]:
|
||||
return STANDARD_SHOT_TASK_TYPES + custom_types
|
||||
|
||||
|
||||
def create_default_tasks_for_shot(shot: Shot, task_types: List[str], db: Session):
|
||||
def create_default_tasks_for_shot(shot: Shot, task_types: List[str], db: Session, project: Project = None):
|
||||
"""Create default tasks for a shot."""
|
||||
created_tasks = []
|
||||
|
||||
|
||||
for task_type in task_types:
|
||||
task_name = f"{shot.name}_{task_type}"
|
||||
task_description = f"{task_type.title()} task for shot {shot.name}"
|
||||
|
||||
|
||||
task = Task(
|
||||
project_id=shot.project_id,
|
||||
episode_id=shot.episode_id,
|
||||
shot_id=shot.id,
|
||||
task_type=task_type,
|
||||
name=task_name,
|
||||
description=task_description
|
||||
description=task_description,
|
||||
department=find_owning_department(project, task_type) if project else None
|
||||
)
|
||||
|
||||
|
||||
db.add(task)
|
||||
created_tasks.append(task)
|
||||
|
||||
|
||||
return created_tasks
|
||||
|
||||
|
||||
@@ -420,7 +422,8 @@ async def create_shot(
|
||||
all_task_types = get_all_shot_task_types(episode.project_id, db)
|
||||
# Use default standard types for now (can be customized via project settings)
|
||||
default_task_types = get_default_shot_task_types()
|
||||
created_tasks = create_default_tasks_for_shot(db_shot, default_task_types, db)
|
||||
project = db.query(Project).filter(Project.id == episode.project_id).first()
|
||||
created_tasks = create_default_tasks_for_shot(db_shot, default_task_types, db, project)
|
||||
db.commit()
|
||||
task_count = len(created_tasks)
|
||||
|
||||
@@ -498,7 +501,8 @@ async def create_shots_bulk(
|
||||
|
||||
created_shots = []
|
||||
total_tasks_created = 0
|
||||
|
||||
project = db.query(Project).filter(Project.id == project_id).first()
|
||||
|
||||
try:
|
||||
# Create all shots - validation already done above
|
||||
for i, shot_name in enumerate(shot_names_to_create):
|
||||
@@ -525,7 +529,7 @@ async def create_shots_bulk(
|
||||
# Create default tasks if requested
|
||||
task_count = 0
|
||||
if bulk_shot.create_default_tasks:
|
||||
created_tasks = create_default_tasks_for_shot(db_shot, task_types, db)
|
||||
created_tasks = create_default_tasks_for_shot(db_shot, task_types, db, project)
|
||||
task_count = len(created_tasks)
|
||||
total_tasks_created += task_count
|
||||
|
||||
@@ -694,6 +698,7 @@ async def create_shot_task(
|
||||
|
||||
# Create the task
|
||||
task_name = f"{shot.name} - {task_type.title()}"
|
||||
project = db.query(Project).filter(Project.id == shot.project_id).first()
|
||||
db_task = Task(
|
||||
project_id=shot.project_id,
|
||||
episode_id=shot.episode_id,
|
||||
@@ -701,7 +706,8 @@ async def create_shot_task(
|
||||
task_type=task_type,
|
||||
name=task_name,
|
||||
description=f"{task_type.title()} task for {shot.name}",
|
||||
status="not_started"
|
||||
status="not_started",
|
||||
department=find_owning_department(project, task_type)
|
||||
)
|
||||
|
||||
db.add(db_task)
|
||||
|
||||
Reference in New Issue
Block a user