def drive_batch_audit(request): if not request.is_ajax(): return HttpResponse('异常请求') ids = request.POST["ids"] id_list = ids.split(',') reserve_logic = ReserveLogic() msg = "" for id in id_list: if id == u'': continue reserve = DriveReserve.objects.get(pk=id) sms_logic = SMSLogic(reserve.user) try: if reserve.audit_status == 0: if not reserve.is_past_due: reserve_logic.pass_reserve(reserve.id, '') sms_logic.send_reserve_sms(reserve.id) else: msg += reserve.user.name + "(过期), " else: msg += reserve.user.name + "(跳过), " except Exception as e: logger.error(e.message) messages.success(request, '操作成功! ' + msg) return ajax_ok(message=u'操作成功')
def drive_batch_delete(request): if not request.is_ajax(): return ajax_fail(message=u'异常请求') ids = request.POST["ids"] id_list = ids.split(',') for id in id_list: if id == u'': continue drive = DriveReserve.objects.get_or_none(pk=int(id)) if drive: drive.delete() return ajax_ok(message=u'操作成功')
def exam_batch_delete(request): if not request.is_ajax(): return ajax_fail(message='异常请求') ids = request.POST["ids"] id_list = ids.split(',') for id in id_list: if id == u'': continue exam = ExamReserve.objects.get_or_none(pk=int(id)) if exam: exam.delete() messages.success(request, '记录删除成功') return ajax_ok(message='操作成功')
def smslog_batch_delete(request): if not request.is_ajax(): return ajax_fail(message='异常请求') ids = request.POST["ids"] id_list = ids.split(',') for id in id_list: if id == u'': continue smslog = SMSSendLog.objects.get_or_none(pk=int(id)) if smslog: smslog.delete() messages.success(request, '记录删除成功') return ajax_ok(message='操作成功')
def exam_batch_audit(request): if not request.is_ajax(): return ajax_fail(message='异常请求') ids = request.POST["ids"] id_list = ids.split(',') reserve_logic = ExamReserveLogic() for id in id_list: if id == u'': continue reserve = ExamReserve.objects.get(pk=int(id)) sms_logic = SMSLogic(reserve.user) try: if reserve.audit_status == 0: reserve_logic.pass_reserve(reserve.id) sms_logic.send_exam_reserve_sms(reserve.id) except Exception as e: logger.error(e.message) messages.success(request, '审核成功') return ajax_ok(message='操作成功')
def exam_check(request): if not request.is_ajax(): return ajax_fail(message=u'异常请求') id = request.POST["id"] type = request.POST["type"] reserve_logic = ExamReserveLogic() reserve = ExamReserve.objects.get(pk=id) sms_logic = SMSLogic(reserve.user) try: if type == "refuse": reserve_logic.refuse_reserve(reserve.id) sms_logic.refuse_exam_reserve_sms(reserve.id) if type == "pass": reserve_logic.pass_reserve(reserve.id) sms_logic.send_exam_reserve_sms(reserve.id) return ajax_ok(message=u'操作成功') except Exception as e: return ajax_fail(message=u'操作失败' + e.message)
def drive_toggle_alert(request): if not request.is_ajax() and request.POST.get('id'): return ajax_fail(message=u'异常请求') drive_id = request.POST.get('id') DriveReserve.objects.extra(where=['id IN (' + drive_id + ')']).update(is_alert=True) return ajax_ok(message=u'修改成功')