Example #1
0
def add_empleado_view(request):
    info = "iniciado"
    if request.method == "POST":
        form = addEmpleadoForm(request.POST,request.FILES)
        if form.is_valid():
            add = form.save(commit=False)
            add.status = True
            add.save() # Guardamos la informacion                  
            info = "Guardado satisfactoriamente"
            return HttpResponseRedirect('/empleado/%s'%add.id)
    else:
        form = addEmpleadoForm()
    ctx = {'form':form,'informacion':info}
    return render_to_response('RecursosDeEmpresa/addEmpleado.html',ctx,context_instance=RequestContext(request)) 
Example #2
0
def edit_empleado_view(request,id_emp):
    info = "iniciado"
    emp = Empleado.objects.get(pk=id_emp)
    if request.method == "POST":
        form = addEmpleadoForm(request.POST,request.FILES,instance=emp)
        if form.is_valid():
            edit_emp = form.save(commit=False)            
            edit_emp.status = True
            edit_emp.save() # Guardamos el objeto
            info = "Correcto"
            return HttpResponseRedirect('/empleado/%s/'%edit_emp.legajo)
    else:
        form = addEmpleadoForm(instance=emp)
    ctx = {'form':form,'informacion':info}
    return render_to_response('RecursosDeEmpresa/editEmpleado.html',ctx,context_instance=RequestContext(request))