def is_save(self, request): cleaned_data = super(OnlineAuditForm, self).clean() title = cleaned_data.get('title') + '_[' + datetime.now().strftime( "%Y%m%d%H%M%S") + ']' verifier = cleaned_data.get('verifier') operator = cleaned_data.get('operator') email_cc = self.data.get('email_cc_id') group_id = cleaned_data.get('group_id') host = cleaned_data.get('host') database = cleaned_data.get('database') operate_type = cleaned_data.get('operate_type') contents = cleaned_data.get('contents') result = IncepSqlCheck(contents, host, database, request.user.username).is_check_pass() if result.get('status') == 2: context = result else: AuditContents.objects.create(title=title, operate_type=operate_type, host=host, database=database, group_id=group_id, proposer=request.user.username, operator=operator, verifier=verifier, email_cc=email_cc) # 向子表插入关联数据 OlAuditDetail.objects.create(ol=AuditContents.objects.latest('id'), contents=contents) # 发送通知邮件 latest_id = AuditContents.objects.latest('id').id send_commit_mail.delay(latest_id=latest_id) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, title=title, type='commit') context = {'status': 0, 'jump_url': '/projects/ol/ol_records/'} return context
def is_save(self, request): cleaned_data = super(WorkOrderAuditForm, self).clean() title = cleaned_data.get('title') + '_[' + datetime.now().strftime("%Y%m%d%H%M%S") + ']' url = cleaned_data.get('url') tasks = cleaned_data.get('tasks') operator = cleaned_data.get('operator') envi_desc = cleaned_data.get('envi_desc') remark = cleaned_data.get('remark') jump_url = cleaned_data.get('jump_url') host, port, database = cleaned_data.get('database').split(',') operate_type = cleaned_data.get('operate_type') contents = cleaned_data.get('contents') result = IncepSqlCheck(contents, host, port, database, request.user.username).is_check_pass() if result.get('status') == 2: context = result else: obj = AuditContents.objects.create( title=title, url=url, tasks=tasks, operate_type=operate_type, host=host, database=database, port=port, envi_desc=envi_desc, remark=remark, proposer=request.user.username, operator=operator, contents=contents ) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, id=obj.id, type='commit') # 跳转到工单记录页面 context = {'status': 0, 'jump_url': jump_url} return context