From c92fd553e1221676d49c224dfe45714d11928838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Wed, 18 Nov 2020 12:31:45 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20exibi=C3=A7=C3=A3o=20de=20campos=20po?= =?UTF-8?q?r=20permiss=C3=A3o=20(#3321)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Edward <9326037+edwardoliveira@users.noreply.github.com> Co-authored-by: Edward <9326037+edwardoliveira@users.noreply.github.com> --- sapl/api/views.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sapl/api/views.py b/sapl/api/views.py index eb6451970..a5ebaabf5 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -22,7 +22,8 @@ from rest_framework.viewsets import ModelViewSet from sapl.api.forms import SaplFilterSetMixin from sapl.api.permissions import SaplModelPermissions -from sapl.api.serializers import ChoiceSerializer, ParlamentarEditSerializer, ParlamentarResumeSerializer +from sapl.api.serializers import ChoiceSerializer, ParlamentarSerializer,\ + ParlamentarEditSerializer, ParlamentarResumeSerializer from sapl.base.models import Autor, AppConfig, DOC_ADM_OSTENSIVO from sapl.materia.models import Proposicao, TipoMateriaLegislativa,\ MateriaLegislativa, Tramitacao @@ -382,10 +383,6 @@ class _AutorViewSet: class _ParlamentarViewSet: class ParlamentarPermission(SaplModelPermissions): def has_permission(self, request, view): - - if request.user.has_perm('parlamentares.add_parlamentar'): - self.serializer_class = ParlamentarEditSerializer - if request.method == 'GET': return True else: @@ -394,6 +391,11 @@ class _ParlamentarViewSet: permission_classes = (ParlamentarPermission, ) + def get_serializer(self, *args, **kwargs): + if self.request.user.has_perm('parlamentares.add_parlamentar'): + self.serializer_class = ParlamentarEditSerializer + return super().get_serializer(*args, **kwargs) + @action(detail=True) def proposicoes(self, request, *args, **kwargs): """