Browse Source

Corrige exibição de campos por permissão (#3321)

Co-Authored-By: Edward <9326037+edwardoliveira@users.noreply.github.com>

Co-authored-by: Edward <9326037+edwardoliveira@users.noreply.github.com>
pull/3304/head
Vinícius Cantuária 4 years ago
committed by GitHub
parent
commit
c92fd553e1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      sapl/api/views.py

12
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):
"""

Loading…
Cancel
Save