def is_save(self, request): cleaned_data = super(OnlineFeedbackForm, self).clean() id = cleaned_data.get('id') status = cleaned_data.get('status') addition_info = cleaned_data.get('addition_info') data = AuditContents.objects.get(pk=id) context = {} # 当记录关闭时 if data.progress == '5': context = {'status': 2, 'msg': '该记录已被关闭、请不要重复提交'} # 当记录未关闭时 else: # 当进度状态为:已批准或处理中时 if data.progress == '2' or data.progress == '3': # 当用户点击的是处理中, 状态变为:处理中 if status == u'处理中': data.progress = '3' data.save() send_verify_mail.delay(latest_id=id, type='feedback', username=request.user.username, user_role=request.user.user_role(), addition_info=addition_info) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, title=data.title, type='feedback', progress='3') context = {'status': 0, 'msg': '操作成功、正在处理中'} # 当用户点击的是已完成, 状态变为:已完成 elif status == u'已完成': data.progress = '4' data.operate_time = timezone.now() data.save() send_verify_mail.delay(latest_id=id, type='feedback', username=request.user.username, user_role=request.user.user_role(), addition_info=addition_info) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, title=data.title, type='feedback', progress='4') context = {'status': 0, 'msg': '操作成功、处理完成'} # 未批准 elif data.progress == '1' or data.progress == '0': context = {'status': 2, 'msg': '操作失败、审核未通过'} # 其他情况 else: context = {'status': 2, 'msg': '操作失败、请不要重复提交'} return context
def is_save(self, request): cleaned_data = super(OnlineApproveForm, self).clean() id = cleaned_data.get('id') status = cleaned_data.get('status') addition_info = cleaned_data.get('addition_info') data = AuditContents.objects.get(pk=id) context = {} # 当记录关闭时 if data.progress == '5': context = {'status': 2, 'msg': '该记录已被关闭、请不要重复提交'} # 当记录未关闭时 else: if data.progress == '0' or data.progress == '1': # 当用户点击的是通过, 状态变为:已批准 if status == u'通过': data.progress = '2' data.verifier_time = timezone.now() data.save() send_verify_mail.delay(latest_id=id, type='approve', username=request.user.username, user_role=request.user.user_role(), addition_info=addition_info) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, title=data.title, type='approve', progress='2') context = {'status': 0, 'msg': '操作成功、审核通过'} # 当用户点击的是不通过, 状态变为:未批准 elif status == u'不通过': data.progress = '1' data.verifier_time = timezone.now() data.save() send_verify_mail.delay(latest_id=id, type='approve', username=request.user.username, user_role=request.user.user_role(), addition_info=addition_info) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, title=data.title, type='approve', progress='1') context = {'status': 0, 'msg': '操作成功、审核未通过'} # 其他情况 else: context = {'status': 2, 'msg': '操作失败、请不要重复提交'} return context
def is_save(self, request): cleaned_data = super(OnlineCloseForm, self).clean() id = cleaned_data.get('id') status = cleaned_data.get('status') addition_info = cleaned_data.get('addition_info') data = AuditContents.objects.get(pk=id) context = {} # 当记录关闭时 if data.progress == '5': context = {'status': 2, 'msg': '该记录已被关闭、请不要重复提交'} # 当记录未关闭时 else: if len(addition_info) >= 5: # 当进度为:处理中或已完成时 if status == u'提交': if data.progress == '3' or data.progress == '4': context = {'status': 2, 'msg': '操作失败、数据正在处理中或已完成'} else: data.progress = '5' data.close_user = request.user.username data.close_reason = addition_info data.close_time = timezone.now() data.save() send_verify_mail.delay( latest_id=id, type='close', username=request.user.username, user_role=request.user.user_role(), addition_info=addition_info) # 发送钉钉推送 xiaoding_pull.delay(user=request.user.username, title=data.title, type='close', progress='5') context = {'status': 0, 'msg': '操作成功、记录关闭成功'} elif status == u'结束': context = {'status': 2, 'msg': '操作失败、关闭窗口'} else: context = {'status': 2, 'msg': '操作失败、<关闭原因>不能少于5个字符'} return context