def get_instance_context(obj): try: taskflow = TaskFlowInstance.objects.get(pipeline_instance=obj) except TaskFlowInstance.DoesNotExist: logger.warning( 'TaskFlowInstance Does not exist: pipeline_template.id=%s' % obj.pk) return {} operator = obj.executor biz_cc_id = taskflow.business.cc_id executor, _ = get_biz_maintainer_info(biz_cc_id, operator, use_in_context=True) context = { 'language': translation.get_language(), 'biz_cc_id': biz_cc_id, 'biz_cc_name': taskflow.business.cc_name, # 执行任务的操作员 'operator': operator, # 调用ESB接口的执行者 'executor': executor, 'task_id': taskflow.id, 'task_name': taskflow.pipeline_instance.name } return context
def __init__(self, taskflow, operator=''): # 执行任务的操作员 operator = operator or taskflow.executor biz_cc_id = taskflow.business.cc_id # 调用蓝鲸API网关的执行者,一般是业务运维 executor, _ = get_biz_maintainer_info(biz_cc_id, operator, use_in_context=True) self.language = translation.get_language() self.biz_cc_id = biz_cc_id self.biz_cc_name = taskflow.business.cc_name self.biz_supplier_account = taskflow.business.cc_owner self.operator = operator self.executor = executor self.task_id = taskflow.id self.task_name = taskflow.pipeline_instance.name