Exemplo n.º 1
0
def edicao(request, id):
    content = (
        DjangoContentType.objects.all()
    )  # .filter( tbdivisao__id = AuthUser.objects.get( pk = request.user.id ).tbdivisao.id ).order_by('nmtipocaixa')
    instance = get_object_or_404(AuthPermission, id=id)
    if request.method == "POST":

        #        if not request.user.has_perm('sicop.permissao_edicao'):
        #            return HttpResponseRedirect('/excecoes/permissao_negada/')

        if validacao(request):
            f_permissao = AuthPermission(
                id=instance.id,
                name=request.POST["nome"],
                codename=request.POST["codenome"],
                content_type=DjangoContentType.objects.get(pk=1),
            )
            f_permissao.save()

        return HttpResponseRedirect("/permissao/consulta/")

    return render_to_response(
        "core/admin/permissao/edicao.html",
        {"permissao": instance, "content": content},
        context_instance=RequestContext(request),
    )
Exemplo n.º 2
0
def cadastro(request):
    content = (
        DjangoContentType.objects.all()
    )  # .filter( tbdivisao__id = AuthUser.objects.get( pk = request.user.id ).tbdivisao.id ).order_by('nmtipocaixa')

    if request.method == "POST":
        next = request.GET.get("next", "/")
        if validacao(request):
            f_permissao = AuthPermission(
                name=request.POST["nome"],
                codename=request.POST["codenome"],
                content_type=DjangoContentType.objects.get(pk=1),
            )
            f_permissao.save()
            if next == "/":
                return HttpResponseRedirect(response_consulta)
            else:
                return HttpResponseRedirect(next)
    return render_to_response(
        "core/admin/permissao/cadastro.html", {"content": content}, context_instance=RequestContext(request)
    )