|
@ -22,7 +22,8 @@ from rest_framework.viewsets import ModelViewSet |
|
|
|
|
|
|
|
|
from sapl.api.forms import SaplFilterSetMixin |
|
|
from sapl.api.forms import SaplFilterSetMixin |
|
|
from sapl.api.permissions import SaplModelPermissions |
|
|
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.base.models import Autor, AppConfig, DOC_ADM_OSTENSIVO |
|
|
from sapl.materia.models import Proposicao, TipoMateriaLegislativa,\ |
|
|
from sapl.materia.models import Proposicao, TipoMateriaLegislativa,\ |
|
|
MateriaLegislativa, Tramitacao |
|
|
MateriaLegislativa, Tramitacao |
|
@ -382,10 +383,6 @@ class _AutorViewSet: |
|
|
class _ParlamentarViewSet: |
|
|
class _ParlamentarViewSet: |
|
|
class ParlamentarPermission(SaplModelPermissions): |
|
|
class ParlamentarPermission(SaplModelPermissions): |
|
|
def has_permission(self, request, view): |
|
|
def has_permission(self, request, view): |
|
|
|
|
|
|
|
|
if request.user.has_perm('parlamentares.add_parlamentar'): |
|
|
|
|
|
self.serializer_class = ParlamentarEditSerializer |
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'GET': |
|
|
if request.method == 'GET': |
|
|
return True |
|
|
return True |
|
|
else: |
|
|
else: |
|
@ -394,6 +391,11 @@ class _ParlamentarViewSet: |
|
|
|
|
|
|
|
|
permission_classes = (ParlamentarPermission, ) |
|
|
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) |
|
|
@action(detail=True) |
|
|
def proposicoes(self, request, *args, **kwargs): |
|
|
def proposicoes(self, request, *args, **kwargs): |
|
|
""" |
|
|
""" |
|
|