From 4b9908e7da2436328b55063286a94f118e697f8c Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 24 Aug 2016 16:17:11 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20try=20except=20nos=20metodos=20de=20?= =?UTF-8?q?permiss=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/utils.py | 99 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 36 deletions(-) diff --git a/sapl/utils.py b/sapl/utils.py index 6d8a0c7f5..f7cbd2fa9 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -224,73 +224,97 @@ def intervalos_tem_intersecao(a_inicio, a_fim, b_inicio, b_fim): def permissoes_materia(): lista_permissoes = [] - cts = ContentType.objects.filter(app_label='materia') - perms_materia = list(Permission.objects.filter(content_type__in=cts)) - for p in perms_materia: - lista_permissoes.append('materia.' + p.codename) + try: + cts = ContentType.objects.filter(app_label='materia') + perms_materia = list(Permission.objects.filter(content_type__in=cts)) + for p in perms_materia: + lista_permissoes.append('materia.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_comissoes(): lista_permissoes = [] - cts = ContentType.objects.filter(app_label='comissoes') - perms_comissoes = list(Permission.objects.filter(content_type__in=cts)) - for p in perms_comissoes: - lista_permissoes.append('comissoes.' + p.codename) + try: + cts = ContentType.objects.filter(app_label='comissoes') + perms_comissoes = list(Permission.objects.filter(content_type__in=cts)) + for p in perms_comissoes: + lista_permissoes.append('comissoes.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_norma(): lista_permissoes = [] - cts = ContentType.objects.filter(app_label='norma') - perms_norma = list(Permission.objects.filter(content_type__in=cts)) - for p in perms_norma: - lista_permissoes.append('norma.' + p.codename) + try: + cts = ContentType.objects.filter(app_label='norma') + perms_norma = list(Permission.objects.filter(content_type__in=cts)) + for p in perms_norma: + lista_permissoes.append('norma.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_parlamentares(): lista_permissoes = [] - cts = ContentType.objects.filter(app_label='parlamentares') - perms_parlamentares = list(Permission.objects.filter(content_type__in=cts)) - for p in perms_parlamentares: - lista_permissoes.append('parlamentares.' + p.codename) + try: + cts = ContentType.objects.filter(app_label='parlamentares') + perms_parlamentares = list(Permission.objects.filter(content_type__in=cts)) + for p in perms_parlamentares: + lista_permissoes.append('parlamentares.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_protocoloadm(): lista_permissoes = [] - perms_protocolo = Permission.objects.filter( - group__name='Operador de Protocolo Administrativo') - for p in perms_protocolo: - lista_permissoes.append('protocoloadm.' + p.codename) + try: + perms_protocolo = Permission.objects.filter( + group__name='Operador de Protocolo Administrativo') + for p in perms_protocolo: + lista_permissoes.append('protocoloadm.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_adm(): lista_permissoes = [] - perms_adm = Permission.objects.filter( - group__name='Operador Administrativo') - for p in perms_adm: - lista_permissoes.append('protocoloadm.' + p.codename) + try: + perms_adm = Permission.objects.filter( + group__name='Operador Administrativo') + for p in perms_adm: + lista_permissoes.append('protocoloadm.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_sessao(): lista_permissoes = [] - perms_sessao = list(Permission.objects.filter( - group__name='Operador de Sessão Plenária')) - for p in perms_sessao: - lista_permissoes.append('sessao.' + p.codename) + try: + perms_sessao = list(Permission.objects.filter( + group__name='Operador de Sessão Plenária')) + for p in perms_sessao: + lista_permissoes.append('sessao.' + p.codename) + except: + pass return set(lista_permissoes) def permissoes_painel(): lista_permissoes = [] - perms_painel = list(Permission.objects.filter( - group__name='Operador de Painel Eletrônico')) - for p in perms_painel: - lista_permissoes.append('painel.' + p.codename) + try: + perms_painel = list(Permission.objects.filter( + group__name='Operador de Painel Eletrônico')) + for p in perms_painel: + lista_permissoes.append('painel.' + p.codename) + except: + pass return set(lista_permissoes) @@ -304,10 +328,13 @@ def permissao_tb_aux(self): def permissoes_autor(): lista_permissoes = [] - perms_autor = list(Permission.objects.filter( - group__name='Autor')) - for p in perms_autor: - lista_permissoes.append('materia.' + p.codename) + try: + perms_autor = list(Permission.objects.filter( + group__name='Autor')) + for p in perms_autor: + lista_permissoes.append('materia.' + p.codename) + except: + pass return set(lista_permissoes)