def ad_handle_cancel_dor_transcation(request): if request.method=='POST': sno=request.POST.get('sno',None) status=request.POST.get('agree_or_not',"不同意申请") if(status=='同意申请'): test1 = DormitorySchedule.objects.get(sno=sno) test1.delete() DorCheckOut.objects.filter(sno=sno).update(apply_status="申请成功") else: DorCheckOut.objects.filter(sno=sno).update(apply_status="申请失败") return show_admin_index(request)
def ad_handle_live_on_vacation_transcation(request): if request.method=='POST': sno=request.POST.get('sno',None) status=request.POST.get('agree_or_not',"不同意申请") if(status=='同意申请'): StayingOnVacationApplyment.objects.filter(sno=sno).update(apply_status="申请成功") data = StayingOnVacationApplyment.objects.get(sno=sno) stu_data=Student.objects.get(sno=sno) test=StudentStayingRecord(sno=data.sno,sname=data.sname,room_no=data.dor_no,stu_phone=stu_data.stu_phone,start_time=data.start_time,end_time=data.end_time,reason=data.reason,apply_time=data.apply_time,apply_status=data.apply_status) test.save() else: StayingOnVacationApplyment.objects.filter(sno=sno).update(apply_status="申请失败") return show_admin_index(request)
def ad_handle_change_dor_transcation(request): if request.method=="POST": sno=request.POST.get('sno',None) status = request.POST.get('agree_or_not', "不同意申请") if status=='同意申请': dorm_floor_number=request.POST.get('dorm_floor_number',None) dorm_floor=request.POST.get('dorm_floor',None) dorm_number = request.POST.get('dorm_number',None) bed_number=request.POST.get('bed_number',None) print(dorm_floor_number+dorm_floor+dorm_number) DormitorySchedule.objects.filter(sno=sno).update(dor_no=dorm_floor_number,room_no=dorm_floor+dorm_number,bed_no=bed_number) DorChange.objects.filter(sno=sno).update(app_status="申请成功") Student.objects.filter(sno=sno).update(dor_no=dorm_floor_number,room_no=dorm_floor_number+dorm_floor+dorm_number) else: DorChange.objects.filter(sno=sno).update(app_status="申请失败") return show_admin_index(request)
def admin_sign_in(request): if request.method=="POST": user = request.POST.get("username", '') pwd = request.POST.get("password", '') try: obj = DorAdminAccount.objects.get(username=user) request.session['userno'] = obj.ad_no except Exception as err: print(err) return render(request, "index.html", {'error': "用户名不存在"}) if check_password(pwd, obj.password)==False: return render(request, "index.html", {'error': "用户名和密码不匹配"}) try: admin = DormitoryAdmin.objects.get(dorm_admin_no=obj.ad_no) request.session['username']=admin.dorm_admin_name return show_admin_index(request) except Exception as err: print(err) return render(request, "index.html", {'error': "系统中没有该管理员"})