Exemplo n.º 1
0
def nuevo_gasto(request):
    if request.method == 'POST':
        form = GastoForm(data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('f_gastos'))
    else:
        form = GastoForm()

    context = {
        'form': form,
    }
    return render_to_response(
        'efinance/f_nuevo_gasto.html',
         context,
         context_instance = RequestContext(request),
    )
Exemplo n.º 2
0
def nuevo_gasto(request):
    if request.method == 'POST':
        form = GastoForm(data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('f_gastos'))
    else:
        form = GastoForm()

    context = {
        'form': form,
    }
    return render_to_response(
        'efinance/f_nuevo_gasto.html',
        context,
        context_instance=RequestContext(request),
    )
Exemplo n.º 3
0
def modificar_gasto(request,gasto_id):
    gasto = Gasto.objects.get(pk=gasto_id)
    dictionary = model_to_dict(gasto, fields=[], exclude=[])
    if request.method == 'POST':
        form = GastoForm(data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('f_gastos'))
    else:
        form = GastoForm(dictionary)

    context = {
        'form': form,
    }
    return render_to_response(
        'efinance/e_modificar_gasto.html',
         context,
         context_instance = RequestContext(request),
    )
Exemplo n.º 4
0
def modificar_gasto(request, gasto_id):
    gasto = Gasto.objects.get(pk=gasto_id)
    dictionary = model_to_dict(gasto, fields=[], exclude=[])
    if request.method == 'POST':
        form = GastoForm(data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('f_gastos'))
    else:
        form = GastoForm(dictionary)

    context = {
        'form': form,
    }
    return render_to_response(
        'efinance/e_modificar_gasto.html',
        context,
        context_instance=RequestContext(request),
    )