From 903a025035293e5c88e21fcedb379e23bf95a862 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Wed, 28 Sep 2016 09:47:43 -0300 Subject: [PATCH] Conserta outro bug em documento administrativo --- sapl/base/templatetags/common_tags.py | 6 +-- sapl/protocoloadm/views.py | 55 +++++++++++++++------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index ce83e020c..4d66190f2 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -95,11 +95,7 @@ def get_doc_adm_template_perms(user): if app_config.documentos_administrativos == 'O': return True - if user.has_perms(permissoes_adm()): - return True - - else: - return False + return user.has_perms(permissoes_adm()) @register.filter diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 6fcfd76af..c24beb6c4 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -68,24 +68,26 @@ class DocumentoAdministrativoCrud(Crud): def has_permission(self): app_config = AppConfig.objects.last() - if app_config.documentos_administrativos == 'O': - return True - else: - perms = self.get_permission_required() - return self.request.user.has_perms(perms) + if app_config: + if app_config.documentos_administrativos == 'O': + return True + + perms = self.get_permission_required() + return self.request.user.has_perms(perms) class DetailView(PermissionRequiredMixin, CrudDetailView): permission_required = permissoes_adm() def has_permission(self): app_config = AppConfig.objects.last() - if app_config.documentos_administrativos == 'O': - return True - else: - perms = self.get_permission_required() - return self.request.user.has_perms(perms) + if app_config: + if app_config.documentos_administrativos == 'O': + return True + + perms = self.get_permission_required() + return self.request.user.has_perms(perms) class StatusTramitacaoAdministrativoCrud(Crud): @@ -400,12 +402,13 @@ class PesquisarDocumentoAdministrativoView(PermissionRequiredMixin, def has_permission(self): app_config = AppConfig.objects.last() - if app_config.documentos_administrativos == 'O': - return True - else: - perms = self.get_permission_required() - return self.request.user.has_perms(perms) + if app_config: + if app_config.documentos_administrativos == 'O': + return True + + perms = self.get_permission_required() + return self.request.user.has_perms(perms) def get_filterset_kwargs(self, filterset_class): super(PesquisarDocumentoAdministrativoView, @@ -621,24 +624,26 @@ class TramitacaoAdmCrud(MasterDetailCrud): def has_permission(self): app_config = AppConfig.objects.last() - if app_config.documentos_administrativos == 'O': - return True - else: - perms = self.get_permission_required() - return self.request.user.has_perms(perms) + if app_config: + if app_config.documentos_administrativos == 'O': + return True + + perms = self.get_permission_required() + return self.request.user.has_perms(perms) class DetailView(PermissionRequiredMixin, MasterDetailCrud.DetailView): permission_required = permissoes_adm() def has_permission(self): app_config = AppConfig.objects.last() - if app_config.documentos_administrativos == 'O': - return True - else: - perms = self.get_permission_required() - return self.request.user.has_perms(perms) + if app_config: + if app_config.documentos_administrativos == 'O': + return True + + perms = self.get_permission_required() + return self.request.user.has_perms(perms) def get_nome_autor(request):