def post(self, asset_instance_id): args = self.get_arguments() try: revision = int(args["revision"]) try: working_file = files_service.get_working_file( args["working_file_id"] ) working_file_id = working_file["id"] except WorkingFileNotFoundException: pass asset_instance = assets_service.get_asset_instance( asset_instance_id ) entity = assets_service.get_asset(asset_instance["asset_id"]) if not permissions.has_manager_permissions(): user_service.check_has_task_related(entity["project_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) if args["person_id"] is None: person = persons_service.get_current_user() else: person = persons_service.get_person(args["person_id"]) output_file = files_service.create_new_output_revision( asset_instance["asset_id"], working_file_id, output_type["id"], person["id"], task_type["id"], asset_instance_id=asset_instance["id"], revision=revision, name=args["name"], representation=args["representation"], comment=args["comment"], extension=args["extension"] ) output_file_dict = self.add_path_info( output_file, "output", asset_instance, output_type, task_type=task_type, name=args["name"], extension=args["extension"], representation=args["representation"], separator=args["sep"] ) except OutputTypeNotFoundException: return {"message": "Cannot find given output type."}, 400 except PersonNotFoundException: return {"message": "Cannot find given person."}, 400 except EntryAlreadyExistsException: return {"message": "The given output file already exists."}, 400 return output_file_dict, 201
def get(self, asset_instance_id, temporal_entity_id): asset_instance = assets_service.get_asset_instance(asset_instance_id) entity = entities_service.get_entity(asset_instance["asset_id"]) user_service.check_project_access(entity["project_id"]) return files_service.get_output_types_for_instance( asset_instance_id, temporal_entity_id )
def get(self, asset_instance_id): asset_instance = assets_service.get_asset_instance(asset_instance_id) asset = assets_service.get_asset(asset_instance["asset_id"]) user_service.check_project_access(asset["project_id"]) temporal_entity_id = request.args.get("temporal_entity_id") task_type_id = request.args.get("task_type_id") output_type_id = request.args.get("output_type_id") name = request.args.get("name") representation = request.args.get("representation") file_status_id = request.args.get("file_status_id") created_at_since = request.args.get("created_at_since") person_id = request.args.get("person_id") return files_service.get_output_files_for_instance( asset_instance["id"], temporal_entity_id=temporal_entity_id, task_type_id=task_type_id, output_type_id=output_type_id, name=name, representation=representation, file_status_id=file_status_id, created_at_since=created_at_since, person_id=person_id, )
def delete(self, instance_id): """ Delete a comment corresponding at given ID. """ comment = tasks_service.get_comment(instance_id) # TODO: only the self user or a manager can delete a commentary if comment["object_type"] == "Task": task = tasks_service.get_task(comment["object_id"]) user_service.check_project_access(task["project_id"]) self.pre_delete(comment) tasks_service.reset_task_data(comment["object_id"]) self.post_delete(comment) elif comment["object_type"] == "OutputFile": output_file = files_service.get_output_file(comment["object_id"]) if output_file.get("entity_id"): instance = entities_service.get_entity( output_file["entity_id"]) elif output_file.get("asset_instance_id"): instance = assets_service.get_asset_instance( output_file["asset_instance_id"]) user_service.check_project_access(instance["project_id"]) else: current_app.logger.warn("Not yet implemented") return "", 404 deletion_service.remove_comment(comment["id"]) tasks_service.clear_comment_cache(comment["id"]) return "", 204
def post(self, asset_instance_id, temporal_entity_id): args = self.get_arguments() try: revision = int(args["revision"]) try: working_file = files_service.get_working_file( args["working_file_id"]) working_file_id = working_file["id"] except WorkingFileNotFoundException: working_file_id = None asset_instance = assets_service.get_asset_instance( asset_instance_id) entity = assets_service.get_asset(asset_instance["asset_id"]) user_service.check_project_access(entity["project_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) if args["person_id"] is None: person = persons_service.get_current_user() else: person = persons_service.get_person(args["person_id"]) output_file_dict = files_service.create_new_output_revision( asset_instance["asset_id"], working_file_id, output_type["id"], person["id"], task_type["id"], asset_instance_id=asset_instance["id"], temporal_entity_id=temporal_entity_id, revision=revision, name=args["name"], path=args["path"], render_info=args["render_info"], representation=args["representation"], comment=args["comment"], nb_elements=int(args["nb_elements"]), extension=args["extension"], file_status_id=args['file_status_id'], ) if args["path"]: folder_path, file_name = os.path.split(args["path"]) output_file_dict.update({ "folder_path": folder_path, "file_name": file_name }) except OutputTypeNotFoundException: return {"message": "Cannot find given output type."}, 400 except PersonNotFoundException: return {"message": "Cannot find given person."}, 400 except EntryAlreadyExistsException: return {"message": "The given output file already exists."}, 400 return output_file_dict, 201
def test_get_asset_instance(self): self.generate_fixture_scene() self.generate_fixture_scene_asset_instance() self.generate_fixture_shot_asset_instance(self.shot, self.asset_instance) asset_instance = assets_service.get_asset_instance( self.asset_instance.id) self.assertDictEqual(asset_instance, self.asset_instance.serialize())
def get(self, asset_instance_id): asset_instance = assets_service.get_asset_instance(asset_instance_id) entity = entities_service.get_entity(asset_instance["asset_id"]) if not permissions.has_manager_permissions(): user_service.check_has_task_related(entity["project_id"]) return files_service.get_last_output_files_for_instance( asset_instance["id"] )
def get(self, asset_instance_id, output_type_id): asset_instance = assets_service.get_asset_instance(asset_instance_id) asset = assets_service.get_asset(asset_instance["asset_id"]) user_service.check_project_access(asset["project_id"]) files_service.get_output_type(output_type_id) return files_service.get_output_files_for_output_type_and_asset_instance( asset_instance_id, output_type_id )
def get(self, asset_instance_id, temporal_entity_id): asset_instance = assets_service.get_asset_instance(asset_instance_id) entity = entities_service.get_entity(asset_instance["asset_id"]) user_service.check_project_access(entity["project_id"]) return files_service.get_last_output_files_for_instance( asset_instance["id"], temporal_entity_id, output_type_id=request.args.get("output_type_id", None), task_type_id=request.args.get("task_type_id", None), representation=request.args.get("representation", None), file_status_id=request.args.get("file_status_id", None))
def get(self, file_id): output_file = files_service.get_output_file(file_id) if output_file.get("entity_id"): instance = entities_service.get_entity(output_file["entity_id"]) elif output_file.get("asset_instance_id"): instance = assets_service.get_asset_instance( output_file["asset_instance_id"]) user_service.check_project_access(instance["project_id"]) is_client = permissions.has_client_permissions() is_manager = permissions.has_manager_permissions() return files_service.get_comments(file_id, is_client, is_manager)
def get(self, asset_instance_id, temporal_entity_id, output_type_id): representation = request.args.get("representation", None) asset_instance = assets_service.get_asset_instance(asset_instance_id) asset = assets_service.get_asset(asset_instance["asset_id"]) user_service.check_project_access(asset["project_id"]) files_service.get_output_type(output_type_id) return files_service.get_output_files_for_output_type_and_asset_instance( asset_instance_id, temporal_entity_id, output_type_id, representation=representation, )
def post(self, file_id): ( task_status_id, # NOT USED CURRENTLY comment, person_id, created_at, checklist) = self.get_arguments() output_file = files_service.get_output_file(file_id) # TODO: test and maybe check_asset_access if output_file.get("entity_id"): instance = entities_service.get_entity(output_file["entity_id"]) elif output_file.get("asset_instance_id"): instance = assets_service.get_asset_instance( output_file["asset_instance_id"]) user_service.check_project_access(instance["project_id"]) # TODO: improve this task_status = TaskStatus.get_by(short_name="wip") if not task_status: print("no task status") return None, 404 task_status_id = task_status.id if not permissions.has_manager_permissions(): person_id = None created_at = None if person_id: person = persons_service.get_person(person_id) else: person = persons_service.get_current_user() comment = tasks_service.create_comment(object_id=file_id, object_type="OutputFile", files=request.files, person_id=person["id"], task_status_id=task_status_id, text=comment, checklist=checklist, created_at=created_at) comment["task_status"] = task_status.serialize() comment["person"] = person return comment, 201
def post(self, asset_instance_id, temporal_entity_id): args = self.get_arguments() asset_instance = assets_service.get_asset_instance(asset_instance_id) asset = entities_service.get_entity(asset_instance["asset_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) user_service.check_project_access(asset["project_id"]) next_revision_number = files_service.get_next_output_file_revision( asset["id"], output_type["id"], task_type["id"], args["name"], asset_instance_id=asset_instance["id"], temporal_entity_id=temporal_entity_id, ) return {"next_revision": next_revision_number}, 200
def post(self, asset_instance_id, temporal_entity_id): args = self.get_arguments() try: asset_instance = assets_service.get_asset_instance( asset_instance_id) entity = entities_service.get_entity(temporal_entity_id) asset = assets_service.get_asset(asset_instance["asset_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) user_service.check_project_access(asset["project_id"]) user_service.check_entity_access(asset["id"]) folder_path = file_tree_service.get_instance_folder_path( asset_instance, entity, output_type=output_type, task_type=task_type, mode=args["mode"], name=args["name"], representation=args["representation"], revision=args["revision"], sep=args["separator"], ) file_name = file_tree_service.get_instance_file_name( asset_instance, entity, output_type=output_type, task_type=task_type, mode=args["mode"], name=args["name"], revision=args["revision"], ) except MalformedFileTreeException as exception: return ( { "message": str(exception), "received_data": request.json }, 400, ) return {"folder_path": folder_path, "file_name": file_name}, 200
def post(self, asset_instance_id, temporal_entity_id): args = self.get_arguments() asset_instance = assets_service.get_asset_instance(asset_instance_id) asset = entities_service.get_entity(asset_instance["asset_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) if not permissions.has_manager_permissions(): user_service.check_has_task_related(asset["project_id"]) next_revision_number = \ files_service.get_next_output_file_revision( asset["id"], output_type["id"], task_type["id"], args["name"], asset_instance_id=asset_instance["id"], temporal_entity_id=temporal_entity_id ) return {"next_revision": next_revision_number}, 200
def post(self, asset_instance_id): args = self.get_arguments() try: asset_instance = assets_service.get_asset_instance( asset_instance_id) asset = assets_service.get_asset(asset_instance["asset_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) if not permissions.has_manager_permissions(): user_service.check_has_task_related(asset["project_id"]) folder_path = file_tree_service.get_instance_folder_path( asset_instance, output_type=output_type, task_type=task_type, mode=args["mode"], name=args["name"], representation=args["representation"], revision=args["revision"], sep=args["separator"] ) file_name = file_tree_service.get_instance_file_name( asset_instance, output_type=output_type, task_type=task_type, mode=args["mode"], name=args["name"], revision=args["revision"] ) except MalformedFileTreeException as e: current_app.logger.error(e) return { "error": "Tree is not properly written, check modes and variables", "received_data": request.json, }, 400 return {"path": folder_path, "name": file_name}, 200