def get(self, task_id): try: task = task_info.get_task(task_id) except TaskNotFoundException: abort(404) next_revision_number = \ file_info.get_next_output_revision_number(task) return {"next_revision": next_revision_number}, 200
def test_get_task(self): self.assertRaises(TaskNotFoundException, task_info.get_task, "wrong-id") task = task_info.get_task(self.task_id) self.assertEqual(self.task_id, task.id) self.output_file.delete() self.working_file.delete() task.delete() self.assertRaises(TaskNotFoundException, task_info.get_task, self.task_id)
def post(self): ( mode, task_id, version, comment, separator ) = self.get_arguments() try: task = task_info.get_task(task_id) file_path = file_tree.get_folder_path( task, mode=mode, sep=separator ) file_name = file_tree.get_file_name( task, mode=mode, version=version, comment=comment ) except TaskNotFoundException: return { "error": "Given task does not exist.", "received_data": request.json, }, 400 except SequenceNotFoundException: return { "error": "Sequence for shot linked to task not found.", "received_data": request.json, }, 400 except MalformedFileTreeException: return { "error": "Tree is not properly written, check modes and variables", "received_data": request.json, }, 400 return {"path": file_path, "name": file_name}, 200
def get(self, instance_id): try: task = task_info.get_task(instance_id) except TaskNotFoundException: abort(404) result = task.serialize() task_type = TaskType.get(task.task_type_id) result["task_type"] = task_type.serialize() assigner = Person.get(task.assigner_id) result["assigner"] = assigner.serialize() project = Project.get(task.project_id) result["project"] = project.serialize() task_status = TaskStatus.get(task.task_status_id) result["task_status"] = task_status.serialize() entity = Entity.get(task.entity_id) result["entity"] = entity.serialize() assignees = [] for assignee in task.assignees: assignees.append(assignee.serialize()) result["persons"] = assignees return result, 200
def assign_task(self, task_id, person_id): task = task_info.get_task(task_id) person = person_info.get_person(person_id) return task_info.assign_task(task, person)