Exemplo n.º 1
0
def liaison_all_detail(request, pk):
    """联系人详情"""
    liaison = get_object_or_404(Liaison, pk=pk, is_valid=True)
    form = LiaisonForm(instance=liaison)
    return render(request, 'liaison_all_detail.html', {
        'form': form,
    })
Exemplo n.º 2
0
def customer_detail_liaison(request, pk):
    """客户详情里查看联系人"""
    liaison = get_object_or_404(Liaison, pk=pk, is_valid=True)
    form = LiaisonForm(instance=liaison)
    return render(request, 'customer_detail_liaison.html', {
        'form': form,
        'liaison': liaison
    })
Exemplo n.º 3
0
def liaison_edit(request, pk):
    """联系人修改"""
    user = request.session.get('user_id')
    liaison = get_object_or_404(Liaison, pk=pk, user=user, is_valid=True)
    if request.method == 'POST':
        form = LiaisonForm(data=request.POST, instance=liaison)
        if form.is_valid():
            form.save()
            return redirect('liaison')
        else:
            print(form.errors.as_json)
    else:
        form = LiaisonForm(instance=liaison)
    return render(request, 'liaison_edit.html', {'form': form, 'pk': pk})
Exemplo n.º 4
0
def liaison_add(request):
    """联系人添加"""
    user_id = request.session.get('user_id')
    customers = Customer.objects.filter(user=user_id)
    if request.method == 'POST':
        form = LiaisonForm(data=request.POST)
        if form.is_valid():
            form.save()
            return redirect('liaison')
        else:
            print(form.errors.as_json)
    else:
        form = LiaisonForm()
    return render(request, 'liaison_add.html', {
        'form': form,
        'customers': customers
    })
Exemplo n.º 5
0
def customer_add_liaison(request, pk):
    """客户详情里添加联系人"""
    customer = get_object_or_404(Customer, pk=pk, is_valid=True)
    if request.method == 'POST':
        form = LiaisonForm(data=request.POST)
        if form.is_valid():
            form.save()
            return redirect('customer_detail', pk)
        else:
            print(form.errors.as_json)
    else:
        form = LiaisonForm()
    return render(request, 'customer_add_liaison.html', {
        'form': form,
        'customer': customer,
        'pk': pk,
    })
Exemplo n.º 6
0
def customer_edit_liaison(request, pk):
    """客户详情里修改联系人"""
    user = request.session.get('user_id')
    liaison = get_object_or_404(Liaison, pk=pk, user=user, is_valid=True)
    if request.method == 'POST':
        form = LiaisonForm(data=request.POST, instance=liaison)
        if form.is_valid():
            form.save()
            return redirect('customer_detail', liaison.customer.pk)
        else:
            print(form.errors.as_json)
    else:
        form = LiaisonForm(instance=liaison)
    return render(request, 'customer_edit_liaison.html', {
        'form': form,
        'liaison': liaison,
        'pk': pk,
    })