def teacher_class(request): # user_id=request.user.id #当前登陆的ID # classlist=models.UserProfile.objects.get(id=user_id).classlist_set.all()#讲师所教班级 classes_obj = request.user.classlist_set.all() #根据 登陆的ID 获取02班级表 page = Page(request.GET.get('p', 1), len(classes_obj)) #当前页数 默认为1 #总数量 classes_obj = classes_obj[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/teacher_class/') #总页数 传入url return render(request, 'crm/teacher_class.html', locals())
def studyrecords(request, enroll_obj_id): enroll_obj = models.Enrollment.objects.get( id=enroll_obj_id) #根据ID获取06学员报名信息表 studyrecordlist = enroll_obj.studyrecord_set.all() #根据06学员报名信息表的ID获取09学习纪录 page = Page(request.GET.get('p', 1), len(studyrecordlist)) #当前页数 默认为1 #总数量 studyrecordlist = studyrecordlist[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/studyrecords/%s/' % enroll_obj_id) #总页数 传入url return render(request, 'crm/studyrecords.html', locals())
def student_course(request): if request.user.stu_account: enrollmentlist = request.user.stu_account.enrollment_set.all( ) #根据账号表关联的ID获取06学员报名信息表 page = Page(request.GET.get('p', 1), len(enrollmentlist)) #当前页数 默认为1 #总数量 enrollmentlist = enrollmentlist[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/student_course/') #总页数 传入url return render(request, 'crm/student_course.html', locals())
def not_audit(request): # sign=models.Enrollment.objects.all()#所有的报名表 # print(sign,'sign----->') sign = models.Enrollment.objects.filter( contract_agreed=True, contract_approved=False).all() #所有的报名表 page = Page(request.GET.get('p', 1), len(sign)) #当前页数 默认为1 #总数量 sign = sign[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/not_audit/') #总页数 传入url return render(request, 'crm/not_audit.html', locals()) #
def teacher_class_detail(request, class_id): # classes_obj=models.UserProfile.objects.get(id=user_id).classlist_set.get(id=class_id)#所选的班级 classes_obj = request.user.classlist_set.get( id=class_id) #根据 登陆的ID 获取02班级表 courserecordlist = classes_obj.courserecord_set.all( ) #根据 02班级表的ID 获取09学习纪录 page = Page(request.GET.get('p', 1), len(courserecordlist)) # 当前页数 默认为1 #总数量 courserecordlist = courserecordlist[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/teacher_class_detail/%s/' % class_id) #总页数 传入url return render(request, 'crm/teacher_classes_detail.html', locals())
def already_payment(request): # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— # sign=models.Enrollment.objects.all()#所有的报名表 sign = models.Enrollment.objects.filter(contract_approved=True, Pay_cost=True).all() #所有的报名表 page = Page(request.GET.get('p', 1), len(sign)) #当前页数 默认为1 #总数量 sign = sign[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/already_payment/') #总页数 传入url # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— return render(request, 'crm/already_payment.html', locals()) #
def payment(request, enroll_id): # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— # sign=models.Payment.objects.all()#所有的报名表#前端对比用户#缴费记录 # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— enroll_obj = models.Enrollment.objects.get(id=enroll_id) #取对象 # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— sign = models.Payment.objects.filter( customer=enroll_obj.customer).all() #所有的报名表#前端对比用户#缴费记录 # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— errors = {} #错误信息 if request.method == "POST": payment_amount = request.POST.get('amount') #缴费金额 consultant = models.UserProfile.objects.get( id=request.user.id) #财务人员 #当前登陆人 if payment_amount: payment_amount = int(payment_amount) #转数字类型 if payment_amount < 500: errors['err'] = '缴费金额不得低于500元!' else: #生成forms payment_obj = models.Payment.objects.create( customer=enroll_obj.customer, ##客户表 学员 course=enroll_obj.enrolled_class.course, #所报课程 consultant=consultant, # 财务人员 amount=payment_amount, #缴费金额 ) enroll_obj.Pay_cost = True #已缴费 enroll_obj.save() #保存 enroll_obj.customer.status = 0 #修改报名状态 为已报名#根据数据库 enroll_obj.customer.save() #保存 return redirect('/crm/not_payment') #客户表 else: errors['err'] = '金额不能为空!' else: payment_form = forms.PaymentForm() #生成表单 # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— page = Page(request.GET.get('p', 1), len(sign)) # 当前页数 默认为1 #总数量 sign = sign[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/payment/%s/' % enroll_id) # 总页数 传入url # ————————68PerfectCRM实现CRM业务流程(bpm)报名缴费分页———————— return render(request, 'crm/payment.html', locals())
def teacher_lesson_detail(request, class_id, courserecord_id): # classes_obj=models.UserProfile.objects.get(id=request.user.id).classlist_set.get(id=class_id)#所选的班级 classes_obj = request.user.classlist_set.get( id=class_id) # 根据 登陆的ID 获取02班级表 courserecordlist = classes_obj.courserecord_set.get( id=courserecord_id) # 根据 前端的ID 获取08每节课上课纪录表 # studyrecord_list=models.CourseRecord.objects.get(id=courserecord_id).studyrecord_set.all()#取本节课所有学员 studyrecord_list = courserecordlist.studyrecord_set.all( ) # 根据08每节课上课纪录表 #获取09学习纪录 #取本节课所有学员 for i in studyrecord_list: # 循环本节课所有学员 交作业的状态 studyrecord_id = i.id # 获取本节课所有学员的ID if studyrecord_id: # 有获取到ID HOMEWORK_path = '%s/%s/%s/%s/' % (settings.HOMEWORK_DATA, class_id, courserecord_id, studyrecord_id ) # 作业目录 if os.path.exists(HOMEWORK_path): # 判断目录是否存在 try: #防止后台误删文件 file_list = os.listdir(HOMEWORK_path) # 取目录 下的文件 isfile = os.path.isfile( '%s%s' % (HOMEWORK_path, file_list[0])) # 判断是不是文件 studyrecord_list.filter(id=studyrecord_id).update( delivery=isfile) # 更新交付作业状态 except: studyrecord_list.filter(id=studyrecord_id).update( delivery=False) # file_list 出错# 更新交付作业状态 else: studyrecord_list.filter(id=studyrecord_id).update( delivery=False) # 更新交付作业状态 page = Page(request.GET.get('p', 1), len(studyrecord_list)) # 当前页数 默认为1 #总数量 studyrecord_list = studyrecord_list[page.start:page.end] # 切片取当前页的数据 page_str = page.page_str('/crm/teacher_lesson_detail/%s/%s/' % (class_id, courserecord_id)) # 总页数 传入url return render(request, 'crm/teacher_lesson_detail.html', locals())