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:
2026-07-24 08:55:18 +08:00
parent 9bbd3df53c
commit 31d17780a4
11 changed files with 960 additions and 94 deletions
+18 -3
View File
@@ -25,6 +25,7 @@ from schemas.task import (
from utils.auth import get_current_user_from_token, _get_user_from_db, require_role, require_permission, user_has_permission
from utils.notifications import notification_service
from utils.file_handler import file_handler
from utils.departments import find_owning_department
router = APIRouter()
@@ -415,10 +416,16 @@ async def create_task(
# Validate the provided status
if not validate_task_status(db, task.project_id, task_data['status']):
raise HTTPException(
status_code=400,
status_code=400,
detail=f"Invalid status '{task_data['status']}' for this project"
)
# If the task type belongs to a department, that department wins over
# anything explicitly submitted for `department`.
owning_department = find_owning_department(project, task_data.get('task_type'))
if owning_department:
task_data['department'] = owning_department
# Create task
db_task = Task(**task_data)
db.add(db_task)
@@ -829,7 +836,15 @@ async def update_task(
status_code=400,
detail=f"Invalid status '{update_data['status']}' for this project"
)
# If the task type is being changed to one owned by a department, that
# department wins over anything explicitly submitted for `department`.
if 'task_type' in update_data:
project = db.query(Project).filter(Project.id == task.project_id).first()
owning_department = find_owning_department(project, update_data['task_type'])
if owning_department:
update_data['department'] = owning_department
# Update task
for field, value in update_data.items():
setattr(task, field, value)