예제 #1
0
def addProveedores(request):

    if request.method == 'POST':
        # formulario enviado
        proveedoresform = ProveedorForm(request.POST)

        if proveedoresform.is_valid():
            # formulario validado correctamente
            proveedoresform.save()
            return HttpResponseRedirect('/categorias/')

    else:
        # formulario inicial
        formset = ProveedorForm()

    return render_to_response('puntoventa/addProducto.html', { 'formset': ProveedorForm }, context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: apanruning/sifre
def providers_new(request):
    if request.method == "POST":
        form = ProveedorForm(request.POST)
        if form.is_valid():
            obj = form.save()
            return redirect("/providers/new")
    form = ProveedorForm()
    return render(
        request,
        'proveedor_nuevo.html',
        {
            'form':form,   
            'current_time':datetime.datetime.now(),  
        }
    )
예제 #3
0
파일: views.py 프로젝트: apanruning/sifre
def providers_edit(request, id="1"):
    provider = Proveedor.objects.get(pk=id)
    
    if request.method == "POST":
        form = ProveedorForm(request.POST, instance=provider)        
        if form.is_valid():
            obj = form.save()
            return redirect("/providers/"+obj.pk)
    form = ProveedorForm(instance=provider) 
    
    return render(
        request,
        'proveedor_detalle.html',
        {
            'provider':provider,
            'form':form,     
            'current_time':datetime.datetime.now(),
        }
    )