示例#1
0
def consultrecord_change(request, pk=None):
    conrec_obj = models.ConsultRecord.objects.filter(pk=pk).first()

    conrec_form_obj = ConsultRecordForm(request, instance=conrec_obj)

    if request.method == 'POST':
        conrec_form_obj = ConsultRecordForm(request,
                                            request.POST,
                                            instance=conrec_obj)

        if conrec_form_obj.is_valid():
            conrec_form_obj.save()

            ## next 参数
            next = request.GET.get('next')
            if next:
                return redirect(next)

            return redirect('crm:consultrecord_list')
    title = '添加跟进记录' if not pk else '编辑跟进记录'

    return render(request, 'form.html', {
        'form_obj': conrec_form_obj,
        'title': title
    })
示例#2
0
def edid_consult(request, edit_id):
    obj = models.ConsultRecord.objects.filter(id=edit_id).first()
    form_obj = ConsultRecordForm(instance=obj)
    if request.method == 'POST':
        form_obj = ConsultRecordForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('consult_record'))  # 跳转到列表页
    return render(request, 'crm/consultant/edit_consult.html', {"form_obj": form_obj})
示例#3
0
def consult(request, edit_id=None):
    print(edit_id)
    obj = models.ConsultRecord.objects.filter(id=edit_id).first() or models.ConsultRecord(consultant=request.user)
    form_obj = ConsultRecordForm(instance=obj)
    if request.method == 'POST':
        form_obj = ConsultRecordForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('consult_record', args=(0, )))  # 跳转到列表页
    return render(request, 'crm/consultant/edit_consult.html', {"form_obj": form_obj})
示例#4
0
def add_consult(request):
    obj = models.ConsultRecord(consultant=request.user)  # 在内存当中

    form_obj = ConsultRecordForm(instance=obj)
    if request.method == 'POST':
        form_obj = ConsultRecordForm(request.POST)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('consult_record'))       # 跳转到列表页
    return render(request, 'crm/consultant/add_consult.html', {"form_obj": form_obj})
示例#5
0
def add_consult_record(request):
    obj = models.ConsultRecord(consultant=request.user)

    form_obj = ConsultRecordForm(instance=obj)
    if request.method == 'POST':
        form_obj = ConsultRecordForm(request.POST)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('consult_record', args=(0, )))

    return render(request, 'crm/consultant/add_consult_record.html',
                  {'form_obj': form_obj})
示例#6
0
def consult_record(request, edit_id=None):
    obj = models.ConsultRecord.objects.filter(
        id=edit_id).first() or models.ConsultRecord(consultant=request.user)
    form_obj = ConsultRecordForm(instance=obj)
    if request.method == 'POST':
        form_obj = ConsultRecordForm(request.POST, instance=obj)
        if form_obj.is_valid():
            form_obj.save()
            return redirect(reverse('consult_record', args=(0, )))

    return render(request, 'crm/enroll_manage/consult_record.html', {
        'form_obj': form_obj,
        'edit_id': edit_id
    })
示例#7
0
def modify_consult(request, pk=None, customer_id=None):
    user_obj = models.ConsultRecord(consultant=request.user_obj, customer_id=customer_id) if customer_id \
        else models.ConsultRecord.objects.filter(pk=pk).first()
    obj = ConsultRecordForm(instance=user_obj)
    if request.method == 'POST':
        obj = ConsultRecordForm(data=request.POST, instance=user_obj)
        if obj.is_valid():
            obj.save()
            url = request.GET.get('next', '')
            return redirect(url if url else 'consult_record')
    title = '修改记录' if pk else '新增记录'
    return render(request, 'form.html', {
        'obj': obj,
        'title': title,
    })
示例#8
0
文件: sales.py 项目: Dream-thorn/CRM
def consult_record_add_or_edit(request, edit_id=None):
    cr_obj = models.ConsultRecord.objects.filter(
        id=edit_id).first() or models.ConsultRecord(consultant=request.user)
    form_obj = ConsultRecordForm(instance=cr_obj)

    if request.method == 'POST':
        form_obj = ConsultRecordForm(request.POST, instance=cr_obj)

        if form_obj.is_valid():
            form_obj.save()

            return redirect(reverse('consult', args=('0', )))

    return render(request, 'crm/sales/consult_record_add_or_edit.html', {
        'form_obj': form_obj,
        'edit_id': edit_id
    })