def workflowsdetail(request, audit_id): # 按照不同的workflow_type返回不同的详情 audit_detail = Workflow.audit_detail(audit_id) if audit_detail.workflow_type == WorkflowDict.workflow_type['query']: return HttpResponseRedirect( reverse('sql:queryapplydetail', args=(audit_detail.workflow_id, ))) elif audit_detail.workflow_type == WorkflowDict.workflow_type['sqlreview']: return HttpResponseRedirect( reverse('sql:detail', args=(audit_detail.workflow_id, )))
def queryprivaudit(request): # 获取用户信息 user = request.user apply_id = int(request.POST['apply_id']) audit_status = int(request.POST['audit_status']) audit_remark = request.POST.get('audit_remark') if audit_remark is None: audit_remark = '' if Workflow.can_review(request.user, apply_id, 1) is False: context = {'errMsg': '你无权操作当前工单!'} return render(request, 'error.html', context) # 使用事务保持数据一致性 try: with transaction.atomic(): # 获取audit_id audit_id = Workflow.audit_info_by_workflow_id( workflow_id=apply_id, workflow_type=WorkflowDict.workflow_type['query']).audit_id # 调用工作流接口审核 audit_result = workflowOb.auditworkflow(request, audit_id, audit_status, user.username, audit_remark) # 按照审核结果更新业务表审核状态 audit_detail = Workflow.audit_detail(audit_id) if audit_detail.workflow_type == WorkflowDict.workflow_type[ 'query']: # 更新业务表审核状态,插入权限信息 query_audit_call_back(audit_detail.workflow_id, audit_result['data']['workflow_status']) except Exception as msg: logger.error(traceback.format_exc()) context = {'errMsg': msg} return render(request, 'error.html', context) return HttpResponseRedirect( reverse('sql:queryapplydetail', args=(apply_id, )))