Example #1
0
def update_procedimento(request, procedimento_id):
    procedimento = get_object_or_404(Procedimento, id=procedimento_id)
    form = ProcedimentoForm(request.POST or None, instance=procedimento)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            messages.success(request, 'Procedimento alterado com sucesso.')
            return HttpResponseRedirect('/')  # Redirect after POST

    return render_to_response('procedimento/update.html', {'form': form, 'procedimento_id': procedimento_id},
                              context_instance=RequestContext(request))
Example #2
0
def new(request):
    if request.method == 'POST':  # If the form has been submitted...
        form = ProcedimentoForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            form.save()
            return HttpResponseRedirect('/')  # Redirect after POST
    else:
        form = ProcedimentoForm()  # An unbound form

    return render_to_response('procedimento/new.html', {'form': form},
                              context_instance=RequestContext(request))