Exemplo n.º 1
0
def enrollment(request, enrollment_id):
    '''学生注册具体信息'''
    enrollment_obj = models.StudentEnrollment.objects.get(id=enrollment_id)
    if enrollment_obj.contract_agreed:
        if enrollment_obj.contract_aproved and enrollment_obj.customer.email:
            return redirect('/login/')
        return HttpResponse("合同正在审核中,请耐心等待!")

    if request.method == "POST":
        contact_agreed = request.POST.get("contact_agreed")
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer,
                                           data=request.POST)
        if customer_form.is_valid() and contact_agreed:
            customer_form.save()
            enrollment_obj.contract_agreed = True
            enrollment_obj.contract_signed_date = datetime.now()
            enrollment_obj.save()
            return HttpResponse("报名信息已提交,请您耐心等待审批结果!!!")
    elif request.method == 'GET':
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer)
    # """列出已上传文件"""
    uploaded_files = []
    enrollment_upload_dir = os.path.join(conf.settings.CRM_FILE_UPLOAD_DIR,
                                         enrollment_id)
    if os.path.isdir(enrollment_upload_dir):

        uploaded_files = os.listdir(enrollment_upload_dir)

    return render(request, "crm/enrollment.html", locals())
Exemplo n.º 2
0
def enrollment(request, enrollment_id):
    """在线报名表"""

    enrollment_obj = models.StudentEnrollment.objects.get(id=enrollment_id)
    if request.method == "POST":

        customer_form = forms.CustomerForm(instance=enrollment_obj.customer,
                                           data=request.POST)
        if customer_form.is_valid():

            customer_form.save()
            return HttpResponse("提交成功")
    else:
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer)
    return render(request, "crm/enrollment.html", locals())
Exemplo n.º 3
0
def contact_audit(request, enrollment_id):
    '''报名审核'''
    enrollment_obj = models.StudentEnrollment.objects.get(id=enrollment_id)
    if request.method == "POST":
        enrollment_form = forms.EnrollmentForm(instance=enrollment_obj,
                                               data=request.POST)
        if enrollment_form.is_valid():
            if enrollment_form.cleaned_data['contract_agreed']:
                enrollment_obj.contract_aproved = True
            enrollment_form.save()
            # save之前帮客户注册一个userprofile,分配一个统一的初始密码
            new_user_role = models.Role.objects.get(name='学生')
            new_user_obj = models.UserProfile.objects.get_or_create(
                **{
                    'email': enrollment_form.instance.customer.email,
                    'name': enrollment_form.instance.customer.name,
                    'password': '******'
                })[0]
            new_user_obj.role.add(new_user_role)
            new_user_obj.save()
            stu_obj = models.Student.objects.get_or_create(
                customer=enrollment_obj.customer, user=new_user_obj)[0]
            stu_obj.class_grades.add(enrollment_obj.class_grade_id)
            stu_obj.save()
            enrollment_obj.customer.status = 1
            enrollment_obj.customer.save()

            return redirect("/myadmin/CRM/customerinfo/%s/change" %
                            enrollment_obj.customer.id)

    else:
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer)
        enrollment_form = forms.EnrollmentForm(instance=enrollment_obj)
    return render(request, "crm/contact_audit.html", locals())
Exemplo n.º 4
0
def enrollment(request, enrollment_id):
    # Q1:此方法的作用是什么?
    #     A1:学院在线报名地址
    enrollment_obj = models.StudentEnrollment.objects.get(id=enrollment_id)
    if enrollment_obj.contract_agreed:
        return HttpResponse("报名合同正在审核中....")

    if request.method == "POST":
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer,
                                           data=request.POST)
        if customer_form.is_valid():
            customer_form.save()
            enrollment_obj.contract_agreed = True
            enrollment_obj.contract_signed_date = datetime.now()
            enrollment_obj.save()
            return HttpResponse("您已成功提交报名信息,请等待审核通过,欢迎加入打死都不退费老男孩教育!")
    else:
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer)
    return render(request, "crm/enrollment.html", locals())
Exemplo n.º 5
0
def contract_audit(request, enrollment_id):
    # Q1:此方法的作用是什么?
    #     A1:创建一个学生合同审核页面
    enrollment_obj = models.StudentEnrollment.objects.get(id=enrollment_id)
    if request.method == "POST":
        print(request.POST)
        enrollment_form = forms.EnrollmentForm(instance=enrollment_obj,
                                               data=request.POST)
        if enrollment_form.is_valid():
            enrollment_form.save()
            stu_obj = models.Student.objects.get_or_create(
                customer=enrollment_obj.customer)[0]
            stu_obj.class_grades.add(enrollment_obj.class_grade_id)
            stu_obj.save()
            enrollment_obj.customer.status = 1
            enrollment_obj.save()
            return redirect("/kingadmin/CRM/customerinfo/%s/change/" %
                            enrollment_obj.customer.id)

    else:
        customer_form = forms.CustomerForm(instance=enrollment_obj.customer)
        enrollment_form = forms.EnrollmentForm(instance=enrollment_obj)
    return render(request, "crm/contract_audit.html", locals())