diff --git a/sapl/api/views.py b/sapl/api/views.py index 335797ecf..d291d56ec 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -22,7 +22,7 @@ from sapl.api.forms import SaplFilterSetMixin from sapl.api.permissions import SaplModelPermissions from sapl.api.serializers import ChoiceSerializer from sapl.base.models import Autor, AppConfig, DOC_ADM_OSTENSIVO -from sapl.materia.models import Proposicao +from sapl.materia.models import Proposicao, TipoMateriaLegislativa from sapl.parlamentares.models import Parlamentar from sapl.utils import models_with_gr_for_model, choice_anos_com_sessaoplenaria @@ -348,6 +348,23 @@ class _ProposicaoViewSet(SaplSetViews['materia']['proposicao']): return qs +class _TipoMateriaLegislativaViewSet(SaplSetViews['materia']['tipomaterialegislativa']): + + @action(detail=True, methods=['POST']) + def change_position(self, request, *args, **kwargs): + result = { + 'status': 200, + 'message': 'OK' + } + d = request.data + if 'pos_ini' in d and 'pos_fim' in d: + if d['pos_ini'] != d['pos_fim']: + pk = kwargs['pk'] + TipoMateriaLegislativa.objects.reposicione(pk, d['pos_fim']) + + return Response(result) + + class _DocumentoAdministrativoViewSet(SaplSetViews['protocoloadm']['documentoadministrativo']): class DocumentoAdministrativoPermission(SaplModelPermissions): @@ -426,6 +443,7 @@ class _SessaoPlenariaViewSet( SaplSetViews['base']['autor'] = _AutorViewSet.build_class_with_actions() SaplSetViews['materia']['proposicao'] = _ProposicaoViewSet +SaplSetViews['materia']['tipomaterialegislativa'] = _TipoMateriaLegislativaViewSet SaplSetViews['parlamentares']['parlamentar'] = _ParlamentarViewSet diff --git a/sapl/crud/base.py b/sapl/crud/base.py index 5fa4f70e5..0dc11ea5c 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -2,7 +2,6 @@ import logging from braces.views import FormMessagesMixin from crispy_forms.bootstrap import FieldWithButtons, StrictButton -from sapl.crispy_layout_mixin import SaplFormHelper from crispy_forms.layout import Field, Layout from django import forms from django.conf.urls import url @@ -25,6 +24,7 @@ from django.views.generic.base import ContextMixin from django.views.generic.list import MultipleObjectMixin from sapl.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display +from sapl.crispy_layout_mixin import SaplFormHelper from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL, RP_LIST) from sapl.settings import BASE_DIR @@ -449,18 +449,28 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView): if not n: s += '
' continue + m = obj n = n.split('__') for f in n[:-1]: m = getattr(m, f) if not m: break + + ss = '' if m: ss = get_field_display(m, n[-1])[1] ss = ( ('
' if '