Ejemplo n.º 1
0
def editar(request, id_registro):
    # try:
    #     registro = RegistroPonto.objects.get(pk=id_registro)
    # except RegistroPonto.DoesNotExist:
    #     raise Http404()

    # return render_to_response()
    registro = get_object_or_404(RegistroPonto, pk=id_registro, usuario=request.user)
    if request.method == "POST":
        form = FormRegistroPonto(request.POST, request.FILES, instance=registro)
        if form.is_valid():
            registroponto = form.save(commit=False)
            registroponto.usuario = request.user
            registroponto.save()
            return render_to_response("gravado.html",{})
    else:
        form=FormRegistroPonto(instance=registro)

    return render_to_response("editar.html",{'form':form}, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def novo(request):
    if request.method == 'POST':
        form = FormRegistroPonto(request.POST, request.FILES)
        if form.is_valid():
            dados = form.cleaned_data
            registroponto = RegistroPonto(
                dia = dados['dia'],
                hora = dados['hora'],
                tipo = dados['tipo'],
                imagem = '',
                usuario = request.user,
                )
            registroponto.save()


            return render_to_response("gravado.html",{})

    else:
        form = FormRegistroPonto()

    return render_to_response("novoregistro.html",{'form':form}, context_instance=RequestContext(request))