Esempio n. 1
0
def class_detail(request, class_id):
    if request.method == 'POST':
        class_comment_form = forms.comment_form(request.POST, prefix='co')
        if class_comment_form.is_valid():
            c_form = class_comment_form.save(commit=False)
            c_form.备注类型 = '班备注'
            c_form.备注关联id = class_id
            c_form.save()
            return redirect('infoManage:班信息', class_id)

    else:
        class_comment_form = forms.comment_form(prefix='co')
        this_class = get_object_or_404(models.班, id=class_id)
        class_comment = models.备注.objects.filter(备注关联id=class_id, 备注类型='班备注')
        student_list = calculate_current_student_list(this_class=this_class)
        student_age = []
        for student in student_list:
            student_age.append(calculate_age(student.学生编号.学生生日))

        student_age.reverse()

        content = {'class': this_class,
                   'class_comment': class_comment,
                   'class_comment_form': class_comment_form,
                   'students_list': student_list,
                   'students_list_count': len(student_list),
                   'student_age': student_age}
        return render(request, 'class_detail.html', content)
Esempio n. 2
0
def payment_confirm(request, sequence):
    sequence = int(sequence)
    student_model = form_ls[sequence]['student_form'].save(commit=False)
    parent_model = form_ls[sequence]['parent_form'].save(commit=False)
    payment_model = form_ls[sequence]['payment_form'].save(commit=False)
    coupon_model = form_ls[sequence]['coupon_form'].save(commit=False)
    should_pay = payment_model.缴费项目.课程定价 - coupon_model.优惠券编号.优惠券折扣

    if request.method == 'POST':
        payment_actual_amount_form = forms.payment_actual_amount_form(request.POST, prefix='paaf')
        comment_form = forms.comment_form(request.POST, prefix='comment')
        if payment_actual_amount_form.is_valid() and comment_form.is_valid():
            student_model.save()

            payment_actual_amount_model = payment_actual_amount_form.save(commit=False)

            payment_model.缴费学生 = student_model
            payment_model.缴费编号 = ''
            payment_model.缴费金额 = payment_actual_amount_model.缴费金额

            comment_model = comment_form.save(commit=False)

            payment_model.save()
            modified_row = models.缴费.objects.get(id=payment_model.id)
            modified_row.缴费编号 = str(date.today().year) + str(date.today().month) + str(date.today().day) + str(
                "%06d" % payment_model.id)
            modified_row.save()

            if parent_model.与学生关系 != '':
                parent_model.学生编号 = student_model
                parent_model.save()

            if coupon_model.优惠券编号 != '':
                coupon_model.缴费单号 = payment_model
                coupon_model.关联手机号 = parent_model.联系电话
                coupon_model.save()

            if comment_model.备注 != '':
                comment_model.备注类型 = '缴费备注'
                comment_model.备注关联id = payment_model.id
                comment_model.save()

            del form_ls[sequence]
            return redirect('infoManage:缴费详单', payment_model.id)

    else:
        payment_actual_amount_form = forms.payment_actual_amount_form(prefix='paaf')
        comment_form = forms.comment_form(prefix='comment')

    content = {'student_model': student_model, 'parent_model': parent_model,
               'payment_model': payment_model, 'coupon_model': coupon_model,
               'should_pay': should_pay,
               'payment_actual_amount_form': payment_actual_amount_form, 'comment_form': comment_form}

    return render(request, 'payment_confirm.html', content)
Esempio n. 3
0
def payment_detail_record(request, payment_id):
    if request.method == 'POST':
        cf = forms.comment_form(request.POST, prefix='co')
        if cf.is_valid():
            c_form = cf.save(commit=False)
            c_form.备注类型 = '缴费备注'
            c_form.备注关联id = payment_id
            c_form.save()
            return redirect('infoManage:缴费详单', payment_id)
    else:
        cf = forms.comment_form(prefix='co')
        this_payment = get_object_or_404(models.缴费, id=payment_id)
        comment = models.备注.objects.filter(备注关联id=payment_id, 备注类型='缴费备注')
        this_coupon = models.优惠券使用.objects.filter(缴费单号=this_payment)
        content = {'payment_record': this_payment, 'comment': comment, 'c_form': cf,
                   'this_coupon': this_coupon}
        return render(request, 'payment_detail_record.html', content)
Esempio n. 4
0
def students_detail(request, student_id):
    if request.method == 'POST':
        student_comment_form = forms.comment_form(request.POST, prefix='co')
        if student_comment_form.is_valid():
            c_form = student_comment_form.save(commit=False)
            c_form.备注类型 = '学生备注'
            c_form.备注关联id = student_id
            c_form.save()
            return redirect('infoManage:学生信息', student_id)

    else:
        student_comment_form = forms.comment_form(prefix='co')
        this_student = get_object_or_404(models.学生, id=student_id)
        student_comment = models.备注.objects.filter(备注关联id=student_id, 备注类型='学生备注')
        this_student_payment_record = models.缴费.objects.filter(缴费学生=student_id)
        student_age = calculate_age(this_student.学生生日)
        class_assignment = models.班级分配.objects.filter(学生编号=student_id)
        class_state = []
        for class_assign in class_assignment:
            class_state.append(class_state_color(class_assign))
            class_state.append(class_state_color(class_assign))

        class_state.reverse()
        student_assign_form = forms.student_assign_form(prefix='assign')
        parent_contact_form = forms.parent_info_form(prefix='parent')
        payment_form = forms.payment_form(prefix='payment')
        coupon_usage_form = forms.coupon_usage_form(prefix='coupon_usage')

        parent_contact = models.家长联系方式.objects.filter(学生编号=this_student)
        content = {'student': this_student,
                   'parent_contact': parent_contact,
                   'student_comment': student_comment,
                   'student_comment_form': student_comment_form,
                   'student_age': student_age,
                   'student_payment_record': this_student_payment_record,
                   'class_assignment': class_assignment,
                   'class_state_color': class_state,
                   'student_assign_form': student_assign_form,
                   'parent_contact_form': parent_contact_form,
                   'payment_form': payment_form,
                   'coupon_usage_form': coupon_usage_form}
        return render(request, 'student_detail.html', content)