From ee2e0b38db1b9b674eb9011c3e4d1519112fd3c3 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Wed, 14 Sep 2016 08:24:33 -0300 Subject: [PATCH] Otimizacao de codigo de autorizacao em recibo de proposicao --- sapl/materia/views.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index f8160db5f..4f7966118 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -541,16 +541,13 @@ class ReciboProposicaoView(TemplateView): def has_permission(self): perms = self.get_permission_required() - if self.request.user.has_perms(perms): - if (Proposicao.objects.filter( - id=self.kwargs['pk'], - autor__user_id=self.request.user.id).exists()): - return True - else: - return False - else: + if not self.request.user.has_perms(perms): return False + return (Proposicao.objects.filter( + id=self.kwargs['pk'], + autor__user_id=self.request.user.id).exists()) + def get_context_data(self, **kwargs): context = super(ReciboProposicaoView, self).get_context_data( **kwargs)