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 test_get_output_file(self): output_file = files_service.get_output_file(self.output_file.id) self.assertEqual(output_file["id"], str(self.output_file.id)) self.assertRaises( OutputFileNotFoundException, files_service.get_output_file, "unknown", )
def get(self, file_id): try: file_dict = files_service.get_working_file(file_id) task = tasks_service.get_task(file_dict["task_id"]) project_id = task["project_id"] except WorkingFileNotFoundException: file_dict = files_service.get_output_file(file_id) entity = entities_service.get_entity(file_dict["entity_id"]) project_id = entity["project_id"] user_service.check_project_access(project_id) return file_dict
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, file_id): try: file_dict = files_service.get_working_file(file_id) task = tasks_service.get_task(file_dict["task_id"]) project_id = task["project_id"] except WorkingFileNotFoundException: file_dict = files_service.get_output_file(file_id) entity = entities_service.get_entity(file_dict["entity_id"]) project_id = entity["project_id"] if not permissions.has_manager_permissions(): user_service.check_has_task_related(project_id) return file_dict
def post(self, file_id): args = self.get_arguments() try: file_dict = files_service.get_output_file(file_id) entity = entities_service.get_entity(file_dict["entity_id"]) user_service.check_project_access(entity["project_id"]) new_dependent = files_service.create_new_dependent( file_id, args["path"], checksum=args["checksum"], size=args["size"]) except EntryAlreadyExistsException: return {"error": "The given dependent file already exists."}, 400 return new_dependent, 201
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, file_id): args = self.get_arguments() try: file_dict = files_service.get_output_file(file_id) entity = entities_service.get_entity(file_dict["entity_id"]) user_service.check_project_access(entity["project_id"]) user_service.check_entity_access(entity["id"]) new_children = files_service.create_new_children( file_id, args["output_type_id"], size=args["size"], path=args["path"], render_info=args["render_info"], file_status_id=args["file_status_id"], temporal_entity_id=args["temporal_entity_id"]) except EntryAlreadyExistsException: return {"error": "The given children file already exists."}, 400 return new_children, 201