コード例 #1
0
def enrollmentEdit(request, customer_id):
    obj = models.Enrollment.objects.filter(id=customer_id).first()
    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('enrollment'))
    return render(request, 'crm/consultant/edit_enrollment.html', {"form_obj": form_obj})
コード例 #2
0
ファイル: consultant.py プロジェクト: Russell2Young/Luffy_crm
def enrollment_edit(request, record_id):
    obj = models.Enrollment.objects.filter(pk=record_id).first()
    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('enrollment_list', args=('0')))
    return render(request, 'form.html', {'form_obj': form_obj, 'title': '编辑报名记录'})
コード例 #3
0
ファイル: consultant.py プロジェクト: Russell2Young/Luffy_crm
def enrollment_add(request, customer_id):
    obj = models.Enrollment(customer_id=customer_id)
    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('enrollment_list', args=('0')))
    return render(request, 'form.html', {'form_obj': form_obj, 'title': '添加报名记录'})
コード例 #4
0
ファイル: sales.py プロジェクト: Dream-thorn/CRM
def enrollment_add_or_edit(request, customer_id=None, edit_id=None):
    enrollment_obj = models.Enrollment.objects.filter(
        id=edit_id).first() or models.Enrollment(customer_id=customer_id)
    form_obj = EnrollmentForm(instance=enrollment_obj)

    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=enrollment_obj)
        # 如果客户同意协议内容, 则进行校验, 否则取消提交
        if request.POST.get('contract_agreed') == 'on':
            if form_obj.is_valid():
                # 保存报名记录
                obj = form_obj.save()
                # 将这个客户的状态改为已报名
                obj.customer.status = 'signed'
                obj.customer.save()

                next_url = request.GET.get('next')
                if next_url:
                    return redirect(next_url)
                else:
                    return redirect(reverse('enrollment', args=('0', )))

    return render(request, 'crm/sales/enrollment_add_or_edit.html', {
        'form_obj': form_obj,
        'next': request.GET.get('next')
    })
コード例 #5
0
ファイル: views.py プロジェクト: wqqsukida/Python_road
def modify_enrollment(request, pk=None, customer_id=None):
    user_obj = models.Enrollment(
        customer_id=customer_id
    ) if customer_id else models.Enrollment.objects.filter(
        customer_id=pk).first()
    obj = EnrollmentForm(instance=user_obj)
    if request.method == 'POST':
        obj = EnrollmentForm(data=request.POST, instance=user_obj)
        if obj.is_valid():
            obj.save()
            url = request.GET.get('next', '')
            return redirect(url if url else 'list_enrollment')
    return render(request, 'form.html', {'obj': obj})
コード例 #6
0
ファイル: enrollment.py プロジェクト: haitaoli231/MyProject
def enrollment_change(request, customer_id=None, enrollment_id=None):
    obj = models.Enrollment.objects.filter(
        pk=enrollment_id).first() if enrollment_id else models.Enrollment(
            customer_id=customer_id)

    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()

            return redirect(reverse_url(request, 'enrollment_list'))
    title = '编辑报名记录' if enrollment_id else '新增报名记录'
    return render(request, 'form.html', {'form_obj': form_obj, 'title': title})
コード例 #7
0
def enrollment_change(request, customer_id=None, edit_id=None):
    obj = models.Enrollment(
        customer_id=customer_id
    ) if customer_id else models.Enrollment.objects.filter(pk=edit_id).first()
    form_obj = EnrollmentForm(instance=obj)
    title = '添加报名表' if customer_id else '编辑报名表'

    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            next = request.GET.get('next')
            return redirect(next)

    return render(request, 'form.html', {'form_obj': form_obj, 'title': title})
コード例 #8
0
ファイル: consultant.py プロジェクト: Russell2Young/Luffy_crm
def enrollment(request, record_id=None, customer_id=None):
    if customer_id:
        obj = models.Enrollment(customer_id=customer_id)
        title = '添加报名记录'
    else:
        obj = models.Enrollment.objects.filter(pk=record_id).first()
        title = '编辑报名记录'
    # obj = models.Enrollment(customer_id=customer_id) if customer_id else models.Enrollment.objects.filter(pk=record_id).first()
    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('enrollment_list', args=('0')))
    # return render(request, 'form.html', {'form_obj': form_obj, 'title': '添加报名记录' if customer_id else '编辑报名记录'})
    return render(request, 'form.html', {'form_obj': form_obj, 'title': title})
コード例 #9
0
def enrollment(request, customer_id=None, edit_id=None):
    obj = models.Enrollment.objects.filter(
        id=edit_id).first() or models.Enrollment(customer_id=customer_id)
    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            enrollment_obj = form_obj.save()
            # 修改客户的状态
            enrollment_obj.customer.status = 'signed'
            enrollment_obj.customer.save()
            next = request.GET.get('next')
            if next:
                return redirect(next)
            else:
                return redirect(reverse('my_customer'))
    return render(request, 'crm/consultant/enrollment.html',
                  {'form_obj': form_obj})
コード例 #10
0
def enrollment(request, customer_id):

    obj = models.Enrollment(customer_id=customer_id)
    form_obj = EnrollmentForm(instance=obj)
    if request.method == 'POST':
        form_obj = EnrollmentForm(request.POST, instance=obj)
        if form_obj.is_valid():
            enrollment_obj = form_obj.save()

            # 修改客户状态变成已报名
            enrollment_obj.customer.status = 'signed'
            # 保存修改之后的状态
            enrollment_obj.customer.save()

            next = request.GET.get('next')
            if next:
                return redirect(next)
            else:
                return redirect(reverse('my_customer'))
    return render(request, 'crm/consultant/enrollment.html', {"form_obj": form_obj})