Esempio n. 1
0
def edit_order(request, details_id):
    order = Details.objects.get(pk=details_id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            form = DetailsForm(request.POST, instance=order)
            form.save()
            return redirect('congratulation:congr', details_id )
    else:
        form = DetailsForm(instance=order)
    return render(request, 'congratulation/edit_order.html', {'username':auth.get_user(request).username, 'form': form, 'id':details_id})
Esempio n. 2
0
def order(request):
    current_user = request.user
    c = Customer.objects.get(user_id = current_user.id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            a = Details.objects.create(customer_id=c.id, date=datetime.now())
            form = DetailsForm(request.POST, instance=a)
            form.save()
            return HttpResponseRedirect('/congratulation/detail')
    else:
        form = DetailsForm()
    return render(request, 'congratulation/add_order.html', {'username':auth.get_user(request).username, 'form': form, 'id':c.id})
Esempio n. 3
0
def edit_order(request, details_id):
    order = Details.objects.get(pk=details_id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            form = DetailsForm(request.POST, instance=order)
            form.save()
            return redirect('congratulation:congr', details_id)
    else:
        form = DetailsForm(instance=order)
    return render(
        request, 'congratulation/edit_order.html', {
            'username': auth.get_user(request).username,
            'form': form,
            'id': details_id
        })
Esempio n. 4
0
def order(request):
    current_user = request.user
    c = Customer.objects.get(user_id=current_user.id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            a = Details.objects.create(customer_id=c.id, date=datetime.now())
            form = DetailsForm(request.POST, instance=a)
            form.save()
            return HttpResponseRedirect('/congratulation/detail')
    else:
        form = DetailsForm()
    return render(request, 'congratulation/add_order.html', {
        'username': auth.get_user(request).username,
        'form': form,
        'id': c.id
    })