Exemplo n.º 1
0
def cadastro(request):

    form = OrgaoForm()
    if request.method == "POST":
        form = OrgaoForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(r('core:orgao_consulta'))
    return render_to_response('core/orgao/cadastro.html',{'form':form},context_instance = RequestContext(request))
Exemplo n.º 2
0
def edicao(request, id):

    obj = get_object_or_404(Orgao, id=id)
    form = OrgaoForm(instance=obj)
    if request.method == "POST":
        if not request.user.has_perm('core.orgao_edicao'):
            return HttpResponseRedirect('/excecoes/permissao_negada/') 
        form = OrgaoForm(request.POST, instance=obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect( r('core:orgao_consulta') )
    return render_to_response('core/orgao/edicao.html', {"form":form}, context_instance = RequestContext(request))