From c7fbc54b44f151ffaab557db672ccebbbd17ae6a Mon Sep 17 00:00:00 2001 From: Edward <9326037+edwardoliveira@users.noreply.github.com> Date: Tue, 13 Apr 2021 09:33:55 -0300 Subject: [PATCH] Fixes #3382 (#3385) Co-authored-by: eribeiro --- sapl/materia/views.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 3a350441d..a987ea171 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -1241,14 +1241,21 @@ class HistoricoProposicaoView(PermissionRequiredMixin, ListView): ordering = ['-data_hora'] paginate_by = 10 model = HistoricoProposicao - permission_required = ('materia.detail_proposicao', ) + permission_required = ('materia.detail_proposicao_enviada', ) def get_queryset(self): qs = super().get_queryset() + + from sapl.rules import SAPL_GROUP_AUTOR + from django.contrib.auth.models import Group + user = self.request.user - if not user.is_superuser: - autores = Autor.objects.filter(user=user) - qs = qs.filter(proposicao__autor__in=autores) + grupo_autor = Group.objects.get(name=SAPL_GROUP_AUTOR) + + if not user.is_superuser and grupo_autor.user_set.filter( + id=user.id).exists(): + autores = Autor.objects.filter(user=user) + qs = qs.filter(proposicao__autor__in=autores) return qs def get_context_data(self, **kwargs):