Example #1
0
def nueva_resolucion(request):
    if request.method == 'POST':
        formulario = ResolucionForm(request.POST)
        if formulario.is_valid():
            resolucion_previo = formulario.save(commit=False)
            resolucion_previo.registro = request.user
            resolucion_previo.save()
            redireccion = "/resolucion/%i" % (resolucion_previo.id)
            return HttpResponseRedirect(redireccion)
    else:
        formulario = ResolucionForm()
    return render_to_response('nueva_resolucion.html',{'form':formulario}, context_instance=RequestContext(request))
Example #2
0
def editar_resolucion(request, id_resolucion):
    dato = get_object_or_404(Resolucion, pk=id_resolucion)
    if request.method == 'POST':
        formulario = ResolucionForm(request.POST, instance=dato)
        if formulario.is_valid():
            resolucion_previo = formulario.save(commit=False)
            resolucion_previo.registro = request.user
            resolucion_previo.save()
            redireccion = "/resolucion/%i" % (resolucion_previo.id)
            return HttpResponseRedirect(redireccion)
    else:
        formulario = ResolucionForm(instance=dato)
    return render_to_response('editar_resolucion.html',{'form':formulario, 'id':dato.pk}, context_instance=RequestContext(request))