예제 #1
0
파일: views.py 프로젝트: varunok/CRMRieltor
def add_buyer_obj(request):
    if request.method == 'POST':
        form = BuyerForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/buyers')
    else:
        form = BuyerForm()
    return add_buyer(request, form)
예제 #2
0
파일: views.py 프로젝트: varunok/CRMRieltor
def save_edit_buyer(request):
    if request.method == 'POST':
        buyer = Buyer.objects.get(id=request.POST.get('edit'))
        form = BuyerForm(request.POST, instance=buyer)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/buyers')
    else:
        form = BuyerForm()
    return edit_buyer(request, request.POST.get('edit'))
예제 #3
0
def add_buyer(request, form=BuyerForm()):
    form.fields['rieltor'].queryset = UserFullName.objects.filter(
        is_active=True)
    form.fields['loyality'].queryset = UserFullName.objects.filter(
        is_active=True)
    return render(request, 'homes/add_buyer.html', {
        'time': timezone.now(),
        'form': form
    })
예제 #4
0
def add_buyer_obj(request):
    if request.method == 'POST':
        form = BuyerForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/buyers')
    else:
        form = BuyerForm()
    return add_buyer(request, form)
예제 #5
0
def save_edit_buyer(request):
    if request.method == 'POST':
        buyer = Buyer.objects.get(id=request.POST.get('edit'))
        form = BuyerForm(request.POST, instance=buyer)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/buyers')
    else:
        form = BuyerForm()
    return edit_buyer(request, request.POST.get('edit'))
예제 #6
0
def edit_buyer(request, id_buyer):
    buyer = Buyer.objects.get(id=id_buyer)
    form = BuyerForm(instance=buyer)
    form.fields['rieltor'].queryset = UserFullName.objects.filter(
        is_active=True)
    form.fields['loyality'].queryset = UserFullName.objects.filter(
        is_active=True)
    return render(request, 'homes/add_buyer.html', {
        'form': form,
        'edit': True,
        'id_buyer': id_buyer
    })