CRM系统-----学员管理系统---开发客户报名流程
客户报名流程
流程图:
销售录入客户信息----->>销售填写报名表(报那个班级,那个客户报名的),自动生成一个链接,返回给客户填写----->>客户填写个人信息和上传身份证图片,并点击 同意协议内容
----->>销售审核合同并同意----->>生成缴费记录----->>状态更改成已报名
1.销售录入客户信息
2.销售填写报名表
1 def enroll(self):#数据库中不存在的字段 2 # print("enroll",self) 3 return """<a href=/crm/customer/%s/enrollment>报名</a>"""%self.instance.id 4 enroll.display_name = "报名连接"
1 from django.urls import path,re_path 2 from crm import views 3 4 urlpatterns = [ 5 path('index/', views.index,name="sales_index"), 6 re_path('customer/(\d+)/enrollment', views.enrollment,name="enrollment"), 7 re_path('customer/registration/(\d+)/(\w+)/', views.stu_registration,name="stu_registration"), 8 path('customers/', views.customer_list,name="customer_list"), 9 path('my_class/', views.my_class,name="my_class_list"), 10 ]
1 def enrollment(request,customer_id): 2 3 customer_obj = models.Customer.objects.get(id=customer_id) 4 msgs = {} 5 if request.method == "POST": 6 enroll_form = forms.EnrollmentForm(request.POST) 7 8 if enroll_form.is_valid(): 9 msg = """请将此连接发送给客户:http://127.0.0.1:8000/crm/customer/registration/{enroll_obj_id}/{random_str}/""" 10 try: 11 enroll_form.cleaned_data["customer"] = customer_obj 12 enroll_obj=models.Enrollment.objects.create(**enroll_form.cleaned_data) 13 msgs["msg"]=msg.format(enroll_obj_id=enroll_obj.id) 14 except IntegrityError as e: 15 enroll_obj = models.Enrollment.objects.get(customer_id=customer_obj.id, 16 enrolled_class_id=enroll_form.cleaned_data["enrolled_class"].id) 17 enroll_form.add_error("__all__","该用户已存在!不能重复创建!") 18 random_str ="".join(random.sample(string.ascii_lowercase+string.digits,8)) 19 cache.set(enroll_obj.id, random_str, 20) 20 msgs["msg"] = msg.format(enroll_obj_id=enroll_obj.id,random_str=random_str) 21 else: 22 enroll_form =forms.EnrollmentForm() 23 24 return render(request,"sale/enrollment.html",{"enroll_form":enroll_form,"customer_obj":customer_obj,"msgs":msgs}) 25 26 def stu_registration(request,enroll_id,random_str): 27 """后台验证数据""" 28 if cache.get(enroll_id) == random_str: 29 30 enroll_obj =models.Enrollment.objects.get(id=enroll_id) 31 if request.method == "POST": 32 customer_form = forms.CustomerForm(request.POST,instance=enroll_obj.customer) 33 if customer_form.is_valid(): 34 customer_form.save() 35 enroll_obj.contract_agreed = True 36 enroll_obj.save() 37 return render(request,"sale/stu_registration.html",{"stauts":1}) 38 39 else: 40 if enroll_obj.contract_agreed == True: 41 stauts = 1 42 else: 43 stauts = 0 44 customer_form = forms.CustomerForm(instance=enroll_obj.customer) 45 else: 46 return HttpResponse("就不怕你这样") 47 48 49 return render(request,"sale/stu_registration.html",{"customer_form":customer_form, 50 "enroll_obj":enroll_obj,"stauts":stauts})
1 {% extends "index.html" %} 2 3 {% block page-content %} 4 5 <div id="content"> 6 7 <form class="form-horizontal col-lg-5" role="form" method="post">{% csrf_token %} 8 <span style="color: red">{{ enroll_form.errors }}</span> 9 <div class="form-group"> 10 <label class="col-sm-3 control-label">Customer:</label> 11 <div class="col-sm-8">{{ customer_obj }}</div> 12 </div> 13 {% for field in enroll_form %} 14 <div class="form-group"> 15 <label class="col-sm-3 control-label">{{ field.label }}:</label> 16 <div class="col-sm-8">{{ field }}</div> 17 </div> 18 {% endfor %} 19 <input type="submit" value="下一步" class="btn btn-info pull-right" /> 20 </form> 21 22 <div> 23 <ul> 24 {% for k,v in msgs.items %} 25 <li>{{ k }}:{{ v }}</li> 26 {% endfor %} 27 </ul> 28 </div> 29 </div> 30 31 {% endblock %}
1 {% extends "base.html" %} 2 {% load crm_tags %} 3 {% block body %} 4 5 <div class="container col-lg-8 col-md-offset-2"> 6 7 <div class="panel panel-primary "> 8 <div class="panel-heading"> 9 <h3 class="panel-title">老男孩教育报名表</h3> 10 </div> 11 <div class="panel-body"> 12 {% if stauts != 1 %} 13 <span style="color: red">{{ customer_form.errors }}</span> 14 15 <form class="form-horizontal" role="form" method="post" onsubmit="return RegisterFormCheck()">{% csrf_token %} 16 {% for field in customer_form %} 17 <div class="form-group"> 18 <label class="col-sm-2 control-label">{{ field.label }}</label> 19 <div class="col-sm-9"> 20 {{ field }} 21 </div> 22 </div> 23 {% endfor %} 24 <hr/> 25 <div class="form-group"> 26 <label class="col-sm-2 control-label">所报班级</label> 27 <div class="col-sm-9"> 28 {{ enroll_obj.enrolled_class }} 29 </div> 30 </div> 31 <div class="form-group"> 32 <label class="col-sm-2 control-label">课程费用</label> 33 <div class="col-sm-9"> 34 {{ enroll_obj.enrolled_class.course.price }} 35 </div> 36 </div> 37 <div class="form-group"> 38 <label class="col-sm-2 control-label">开课日期</label> 39 <div class="col-sm-9"> 40 {{ enroll_obj.enrolled_class.start_date }} 41 </div> 42 </div> 43 <div class="form-group"> 44 <div class="col-sm-9"> 45 <pre>{% render_enroll_contract enroll_obj %}</pre> 46 </div> 47 </div> 48 <div class="form-group"> 49 <div class="col-sm-9"> 50 <input type="checkbox" name="contract_agreed" />我已认真阅读完毕并接受 51 </div> 52 </div> 53 <div class="text-center"><input type="submit" value="提交" class="btn btn-info" /></div> 54 55 56 57 </form> 58 {% else %} 59 <div>报名成功</div> 60 {% endif %} 61 62 </div> 63 </div> 64 65 </div> 66 67 68 69 <script> 70 function RegisterFormCheck(){ 71 if ($("form :checkbox").prop('checked')){ 72 $("form").find("[disabled]").removeAttr("disabled"); 73 return true; 74 }else{ 75 alert("必须同意条款") 76 return false; 77 } 78 } 79 </script> 80 {% endblock %}
1 from django.forms import ModelForm 2 from crm import models 3 4 5 class CustomerForm(ModelForm): 6 7 def __new__(cls,*args,**kwargs): 8 9 for field_name,field_obj in cls.base_fields.items(): 10 field_obj.widget.attrs["class"] = "form-control" 11 12 if field_name in cls.Meta.readonly_field: 13 field_obj.widget.attrs["disabled"] = "disabled" 14 15 return ModelForm.__new__(cls) 16 17 def clean_qq(self):#禁止修改QQ字段 18 if self.instance.qq != self.cleaned_data["qq"]: 19 self.add_error("qq","禁止修改QQ字段") 20 return self.cleaned_data["qq"] 21 22 class Meta: 23 model = models.Customer 24 fields = "__all__" 25 exclude = ["tags","content","memo","status","referral_form"] 26 readonly_field = ["qq","consultant","source"] 27 28 29 class EnrollmentForm(ModelForm): 30 31 def __new__(cls,*args,**kwargs): 32 33 for field_name,field_obj in cls.base_fields.items(): 34 field_obj.widget.attrs["class"] = "form-control" 35 36 return ModelForm.__new__(cls) 37 38 class Meta: 39 model = models.Enrollment 40 fields =["enrolled_class","consultant"]
3.开发学员报名合同审核及缴费页
1 class PaymentForm(ModelForm): 2 class Meta: 3 model = models.Payment 4 fields = "__all__" 5 exclude = ["customer","course","consultant"]
1 re_path('contract_review/(\d+)/', views.contract_review,name="contract_review"), 2 re_path('payment/(\d+)/', views.payment,name="payment"), 3 re_path('enrollment_rejection/(\d+)/', views.enrollment_rejection,name="enrollment_rejection"),
1 def enrollment(request,customer_id): 2 3 customer_obj = models.Customer.objects.get(id=customer_id) 4 msgs = {} 5 if request.method == "POST": 6 enroll_form = forms.EnrollmentForm(request.POST) 7 8 if enroll_form.is_valid(): 9 msg = """请将此连接发送给客户:http://127.0.0.1:8000/crm/customer/registration/{enroll_obj_id}/{random_str}/""" 10 try: 11 enroll_form.cleaned_data["customer"] = customer_obj 12 enroll_obj=models.Enrollment.objects.create(**enroll_form.cleaned_data) 13 random_str = "".join(random.sample(string.ascii_lowercase + string.digits, 8)) 14 msgs["msg"]=msg.format(enroll_obj_id=enroll_obj.id,random_str=random_str) 15 except IntegrityError as e: 16 enroll_obj = models.Enrollment.objects.get(customer_id=customer_obj.id, 17 enrolled_class_id=enroll_form.cleaned_data["enrolled_class"].id) 18 19 if enroll_obj.contract_agreed:#如果学生已经同意 20 return redirect("/crm/contract_review/%s/"%enroll_obj.id) 21 22 enroll_form.add_error("__all__","该用户已存在!不能重复创建!") 23 random_str ="".join(random.sample(string.ascii_lowercase+string.digits,8)) 24 # cache.set(enroll_obj.id, random_str, 30000)#设置验证的时间 25 msgs["msg"] = msg.format(enroll_obj_id=enroll_obj.id,random_str=random_str) 26 else: 27 enroll_form =forms.EnrollmentForm() 28 29 return render(request,"sale/enrollment.html",{"enroll_form":enroll_form, 30 "customer_obj":customer_obj, 31 "msgs":msgs}) 32 33 def stu_registration(request,enroll_id,random_str): 34 """后台验证数据""" 35 if True:#cache.get(enroll_id) == random_str: 36 37 enroll_obj =models.Enrollment.objects.get(id=enroll_id) 38 if request.method == "POST": 39 if request.is_ajax():#图片的上传 40 print(request.FILES) 41 enroll_data_dir = "%s/%s"%(settings.ENROLLED_DATA,enroll_id)#路径 42 if not os.path.exists(enroll_data_dir): 43 os.makedirs(enroll_data_dir,exist_ok=True) 44 45 for k,file_obj in request.FILES.items(): 46 with open("%s/%s"%(enroll_data_dir,file_obj.name),"wb") as f: 47 for chunk in file_obj.chunks(): 48 f.write(chunk) 49 50 return HttpResponse("sucess") 51 52 customer_form = forms.CustomerForm(request.POST,instance=enroll_obj.customer) 53 if customer_form.is_valid(): 54 customer_form.save() 55 enroll_obj.contract_agreed = True 56 enroll_obj.save() 57 return render(request,"sale/stu_registration.html",{"status":1}) 58 59 else: 60 if enroll_obj.contract_agreed == True: 61 status = 1 62 else: 63 status = 0 64 customer_form = forms.CustomerForm(instance=enroll_obj.customer) 65 66 return render(request,"sale/stu_registration.html",{"customer_form":customer_form, 67 "enroll_obj":enroll_obj,"status":status}) 68 else: 69 return HttpResponse("就不怕你这样") 70 71 72 73 def contract_review(request,enroll_id):#报名信息审核 74 enroll_obj = models.Enrollment.objects.get(id=enroll_id) 75 payment_form = forms.PaymentForm() 76 enroll_form = forms.EnrollmentForm(instance=enroll_obj) 77 customer_form = forms.CustomerForm(instance=enroll_obj.customer) 78 79 return render(request,"sale/contract_review.html",{"enroll_obj":enroll_obj, 80 "enroll_form":enroll_form, 81 "customer_form":customer_form}) 82 83 84 def enrollment_rejection(request,enroll_id):#报名信息的驳回 85 enroll_obj =models.Enrollment.objects.get(id =enroll_id) 86 enroll_obj.contract_agreed = False 87 enroll_obj.save() 88 return redirect("/crm/customer/%s/enrollment/"%enroll_obj.customer_id) 89 90 def payment(request,enroll_id): 91 enroll_obj = models.Enrollment.objects.get(id=enroll_id) 92 errors = [] 93 if request.method == "POST": 94 payment_amount = request.POST.get("amount") 95 if payment_amount: 96 payment_amount = int(payment_amount) 97 if payment_amount < 500: 98 errors.append("缴费金额不得低于500") 99 else: 100 payment_obj =models.Payment.objects.create( 101 customer=enroll_obj.customer, 102 course=enroll_obj.enrolled_class.course, 103 amount=payment_amount, 104 consultant=enroll_obj.customer.consultant 105 ) 106 enroll_obj.contract_approved = True#审核合同按钮 107 enroll_obj.save() 108 109 enroll_obj.customer.status = 0#修改报名情况 110 enroll_obj.customer.save() 111 112 return redirect("/king_admin/crm/customer/") 113 else: 114 errors.append("金额没有填写") 115 116 117 return render(request,"sale/payment.html",{"enroll_obj":enroll_obj, 118 "errors":errors})
1 {% extends "index.html" %} 2 3 {% block page-content %} 4 5 <div id="content"> 6 <h3>学生基本信息审核</h3> 7 {{ customer_form.as_table }} 8 9 10 {# {% for field in payment_form %}#} 11 {# <div class="form-group">#} 12 {# <label class="col-sm-3 control-label">{{ field.label }}:</label>#} 13 {# <div class="col-sm-8">{{ field }}</div>#} 14 {# </div>#} 15 {# {% endfor %}#} 16 17 <hr/> 18 <h3>学生报名信息</h3> 19 {{ enroll_form.as_p }} 20 21 <a href="{% url 'enrollment_rejection' enroll_obj.id %}" class="btn btn-danger" >驳回合同</a> 22 <a href="{% url 'payment' enroll_obj.id %}" class="btn btn-info pull-right" >审核同意</a> 23 24 25 <div> 26 <ul> 27 {% for k,v in msgs.items %} 28 <li>{{ k }}:{{ v }}</li> 29 {% endfor %} 30 </ul> 31 </div> 32 </div> 33 34 {% endblock %}
1 {% extends "index.html" %} 2 3 {% block page-content %} 4 5 <div id="content"> 6 <h3>缴费记录信息</h3> 7 <form class="form-horizontal col-lg-5" role="form" method="post">{% csrf_token %} 8 <div style="color: red"> 9 <ul> 10 {% if error in errors %} 11 <li>{{ error }}</li> 12 {% endif %} 13 </ul> 14 </div> 15 <div class="form-group"> 16 <label class="col-sm-3 control-label">Customer:</label> 17 <div class="col-sm-8">{{ enroll_obj }}</div> 18 </div> 19 <div class="form-group"> 20 <label class="col-sm-3 control-label">所报班级:</label> 21 <div class="col-sm-8">{{ enroll_obj.enrolled_class.course }}</div> 22 </div> 23 <div class="form-group"> 24 <label class="col-sm-3 control-label">课程金额:</label> 25 <div class="col-sm-8"> 26 <input type="text" placeholder="至少500" name="amount" /> 27 </div> 28 </div> 29 30 {# {% for field in payment_form %}#} 31 {# <div class="form-group">#} 32 {# <label class="col-sm-3 control-label">{{ field.label }}:</label>#} 33 {# <div class="col-sm-8">{{ field }}</div>#} 34 {# </div>#} 35 {# {% endfor %}#} 36 <div class="form-group"> 37 <label class="col-sm-3 control-label">课程顾问:</label> 38 <div class="col-sm-8">{{ enroll_obj.customer.consultant }}</div> 39 </div> 40 <input type="submit" value="下一步" class="btn btn-info pull-right" /> 41 </form> 42 43 44 </div> 45 46 {% endblock %}
通过admin action批量生成上课记录
1 class CourseRecordAdmin(admin.ModelAdmin): 2 list_display = ["from_class","day_num","teacher","has_homework","homework_title","date"] 3 4 def initialize_studyrecords(self,request,queryset): 5 if len(queryset) >1: 6 return HttpResponse("只能选择一个班级") 7 8 # print(queryset[0].from_class.enrollment_set.all()) 9 new_obj_list = [] 10 for enroll_obj in queryset[0].from_class.enrollment_set.all(): 11 12 #数据量小的情况下使用 13 # models.StudyRecord.objects.get_or_create( 14 # student=enroll_obj, 15 # course_record=queryset[0], 16 # attendance=0, 17 # score=0, 18 # ) 19 20 #数据量达的情况下使用 21 22 new_obj_list.append(models.StudyRecord( 23 student=enroll_obj, 24 course_record=queryset[0], 25 attendance=0, 26 score=0, 27 )) 28 try: 29 models.StudyRecord.objects.bulk_create(new_obj_list) 30 except Exception as e: 31 return HttpResponse("批量初始化学习记录失败,请检查该节课是否存在相应的学习记录中") 32 33 34 return redirect("/admin/crm/studyrecord/?course_record__id__exact=%s/"%queryset[0]) 35 36 initialize_studyrecords.short_description = "初始化本节所有学生的上课记录" 37 actions = ['initialize_studyrecords'] 38 39 40 class StudyRecordAdmin(admin.ModelAdmin): 41 list_display = ["student","course_record","attendance","score","date"] 42 list_filter = ["course_record","score"] 43 list_editable = ["attendance","score"]
开发学员交作业页面
首先创建学生视图:
1 from django.urls import path,re_path 2 from student import views 3 4 urlpatterns = [ 5 path('index/', views.stu_my_classes,name="stu_my_classes"), 6 re_path('studyrecords/(\d+)/', views.studyrecords,name="studyrecords"), 7 re_path('homework_detail/(\d+)/', views.homework_detail,name="homework_detail"), 8 ]
1 from django.shortcuts import render,HttpResponse 2 from crm import models 3 from PerfectCRM import settings 4 import os,json,time 5 # Create your views here. 6 7 def stu_my_classes(request): 8 9 return render(request,"student/student.html") 10 11 def studyrecords(request,enroll_obj_id): 12 13 enroll_obj = models.Enrollment.objects.get(id=enroll_obj_id) 14 15 return render(request,"student/studyrecords.html",{"enroll_obj":enroll_obj}) 16 17 def homework_detail(request,studyrecord_id): 18 studyrecord_obj = models.StudyRecord.objects.get(id=studyrecord_id) 19 20 21 #存储路径 22 homework_path = "{base_dir}/{class_id}/{course_record_id}/{studyrecord_id}/".format(base_dir=settings.HOMEWORK_DATA, 23 class_id=studyrecord_obj.student.enrolled_class_id, 24 course_record_id=studyrecord_obj.course_record_id, 25 studyrecord_id=studyrecord_obj.id 26 ) 27 if not os.path.isdir(homework_path):#确实是否存在该目录,不存在就创建 28 os.makedirs(homework_path,exist_ok=True) 29 30 31 if request.method == "POST":#文件存储 32 for k, file_obj in request.FILES.items(): 33 with open("%s/%s" % (homework_path, file_obj.name), "wb") as f: 34 for chunk in file_obj.chunks(): 35 f.write(chunk) 36 37 #显示文件上传成功是否 38 file_lists=[] 39 for file_name in os.listdir(homework_path): 40 f_path = "%s/%s"%(homework_path,file_name) 41 modify_time = time.strftime("%Y-%m-%d %H:%M:%S",time.gmtime(os.stat(f_path).st_ctime)) 42 file_lists.append([file_name,os.stat(f_path).st_size,modify_time]) 43 44 if request.method == "POST": 45 return HttpResponse(json.dumps({"status": 0, "msg": "file upload success","file_lists":file_lists})) 46 47 48 return render(request,"student/homework_detail.html",{"studyrecord_obj":studyrecord_obj, 49 "file_lists":file_lists})
1 HOMEWORK_DATA = "%s/homeworks"%BASE_DIR
1 from django import template 2 from django.utils.safestring import mark_safe 3 from django.utils.timezone import datetime,timedelta 4 from django.core.exceptions import FieldDoesNotExist 5 from django.db.models import Sum 6 7 register = template.Library() 8 9 @register.simple_tag 10 def get_score (enroll_obj, customer_obj): 11 study_records =enroll_obj.studyrecord_set.filter(course_record__from_class_id=enroll_obj.enrolled_class.id) 12 13 return study_records.aggregate(Sum("score"))
1 {% extends "index.html" %} 2 {% load stu_tags %} 3 {% block page-content %} 4 5 <div class="container" style="margin: 30px;width: auto"> 6 <div class="row"> 7 <div class="panel panel-info"> 8 <div class="panel-heading"> 9 <h3 class="panel-title">我的课程</h3> 10 </div> 11 <div class="panel-body"> 12 <table class="table table-hover"> 13 <thead> 14 <tr> 15 <th>课程名称</th> 16 <th>班级</th> 17 <th>开课时间</th> 18 <th>结业时间</th> 19 <th>课程进度</th> 20 <th>我的成绩</th> 21 <th>作业管理</th> 22 </tr> 23 </thead> 24 <tbody> 25 {% for enroll_obj in request.user.stu_amount.enrollment_set.all %} 26 27 <tr> 28 <td>{{ enroll_obj.enrolled_class.course }}</td> 29 <td>s{{ enroll_obj.enrolled_class.semester }}</td> 30 <td>{{ enroll_obj.enrolled_class.start_date }}</td> 31 <td>{{ enroll_obj.enrolled_class.end_date }}</td> 32 <td>已上{{ enroll_obj.enrolled_class.courserecord_set.all.count }}节</td> 33 <td>{% get_score enroll_obj request.user.stu_amount as enroll_score %}{{ enroll_score.score__sum }}</td> 34 <td><a href="{% url 'studyrecords' enroll_obj.id %}">作业管理</a></td> 35 </tr> 36 {% endfor %} 37 </tbody> 38 </table> 39 </div> 40 </div> 41 </div> 42 43 </div> 44 45 46 47 {% endblock %}
1 {% extends "index.html" %} 2 {% load stu_tags %} 3 {% block page-content %} 4 5 <div class="container" style="margin: 30px;width: auto"> 6 <div class="row"> 7 <div class="panel panel-info"> 8 <div class="panel-heading"> 9 <h3 class="panel-title">{{ enroll_obj.enrolled_class }}</h3> 10 </div> 11 <div class="panel-body"> 12 <table class="table table-hover"> 13 <thead> 14 <tr> 15 <th>课程节次</th> 16 <th>开课日期</th> 17 <th>是否有作业</th> 18 <th>作业标题</th> 19 <th>签到状态</th> 20 <th>我的成绩</th> 21 <th>作业详情</th> 22 </tr> 23 </thead> 24 <tbody> 25 {% for studyrecord in enroll_obj.studyrecord_set.all %} 26 <tr> 27 <td>{{ studyrecord.course_record.day_num }}</td> 28 <td>{{ studyrecord.course_record.date }}</td> 29 <td>{{ studyrecord.course_record.has_homework }}</td> 30 <td>{{ studyrecord.course_record.homework_title }}</td> 31 <td>{{ studyrecord.get_attendance_display }}</td> 32 <td>{{ studyrecord.get_score_display }}</td> 33 <td><a href="{% url 'homework_detail' studyrecord.id %}">作业</a></td> 34 </tr> 35 {% endfor %} 36 37 </tbody> 38 </table> 39 </div> 40 </div> 41 </div> 42 43 </div> 44 45 46 47 {% endblock %}
1 {% extends "index.html" %} 2 {% load stu_tags %} 3 {% block page-content %} 4 5 <div class="container" style="margin: 30px;width: auto"> 6 <div class="row"> 7 <div class="panel panel-info"> 8 <div class="panel-heading"> 9 <h3 class="panel-title">作业详情</h3> 10 </div> 11 12 <div class="panel-body"> 13 <h4>班级:{{ studyrecord_obj.student.enrolled_class }}</h4> 14 <h4>课程节次:{{ studyrecord_obj.course_record.day_num }}</h4> 15 <h4>作业标题:{{ studyrecord_obj.course_record.homework_title }}</h4> 16 <h4>作业内容:<pre>{{ studyrecord_obj.course_record.homework_content }}</pre></h4> 17 <h4>老师评语:{{ studyrecord_obj.memo }}</h4> 18 <h4>本次成绩:{{ studyrecord_obj.score }}</h4> 19 <h4>上传作业:</h4> 20 <form id="filedropzone" method="post" action="{{ request.path }}" class="dropzone dz-clickable">{% csrf_token %} 21 <div class="dz-default dz-message"> 22 <div class="dz-icon icon-wrap icon-circle icon-wrap-md"> 23 <i class="fa fa-cloud-upload fa-3x"></i> 24 </div> 25 <div> 26 <p class="dz-text">把要提交的作业拖到这里</p> 27 <p class="text-muted">上传前请将代码打包成.zip格式</p> 28 </div> 29 </div> 30 </form> 31 <div class="row"> 32 <p>已上传作业</p> 33 <ul> 34 {% for file in file_lists %} 35 <li>{{ file.0 }}|{{ file.1 }}|{{ file.2 }}</li> 36 {% endfor %} 37 </ul> 38 </div> 39 40 41 </div> 42 </div> 43 </div> 44 45 </div> 46 47 48 {% endblock %} 49 50 {% block bottom-js %} 51 <script> 52 53 $(document).ready(function () { 54 Dropzone.options.filedropzone = { 55 url:"{{ request.path }}", 56 paramName: "file", // The name that will be used to transfer the file 57 maxFilesize: 5, // MB, 58 addRemoveLinks:true, 59 maxFiles:5, 60 uploadMultiple:true, 61 accept: function(file, done) { 62 if (! file.name.endsWith(".zip") ) { 63 alert("只能上传zip格式的压缩包"); 64 } 65 else { done(); } 66 } 67 }; 68 69 Dropzone.autoDiscover = false; 70 myDropzone = new Dropzone("#filedropzone"); 71 myDropzone.on("addedfile",function(file){ 72 console.log("---",file) 73 }); 74 75 myDropzone.on("success",function(file,response){ 76 console.log("filex upload done ...",response); 77 }) 78 79 }) 80 81 82 function RegisterFormCheck(){ 83 if (myDropzone.files.length<2){ 84 alert("必须至少上传2张图片"); 85 return false; 86 }; 87 88 if ($("form :checkbox").prop('checked')){ 89 $("form").find("[disabled]").removeAttr("disabled"); 90 return true; 91 }else{ 92 alert("必须同意条款"); 93 return false; 94 } 95 } 96 </script> 97 {% endblock%}
效果:
#####################################################