Browse Source

refactor: inclui ContentType na API, apenas list e detail

pull/3607/head
LeandroJatai 2 years ago
parent
commit
a9723102b9
  1. 7
      sapl/api/core/__init__.py
  2. 5
      sapl/api/viewset.py
  3. 6
      sapl/rules/group_geral.py

7
sapl/api/core/__init__.py

@ -167,8 +167,11 @@ class SaplApiViewSetConstrutor():
viewset.__name__ = '%sModelSaplViewSet' % _model.__name__ viewset.__name__ = '%sModelSaplViewSet' % _model.__name__
return viewset return viewset
apps_sapl = [apps.apps.get_app_config( apps_sapl = [
n[5:]) for n in settings.SAPL_APPS] apps.apps.get_app_config('contenttypes')
] + [
apps.apps.get_app_config(n[5:]) for n in settings.SAPL_APPS
]
for app in apps_sapl: for app in apps_sapl:
cls._built_sets[app] = {} cls._built_sets[app] = {}
for model in app.get_models(): for model in app.get_models():

5
sapl/api/viewset.py

@ -29,6 +29,11 @@ from sapl.utils import models_with_gr_for_model, choice_anos_com_sessaoplenaria
SaplApiViewSetConstrutor = SaplApiViewSetConstrutor.build_class() SaplApiViewSetConstrutor = SaplApiViewSetConstrutor.build_class()
@customize(ContentType)
class _ContentTypeSet:
http_method_names = ['get', 'head', 'options', 'trace']
@customize(Autor) @customize(Autor)
class _AutorViewSet: class _AutorViewSet:
# Customização para AutorViewSet com implementação de actions específicas # Customização para AutorViewSet com implementação de actions específicas

6
sapl/rules/group_geral.py

@ -1,3 +1,5 @@
from django.contrib.contenttypes import models as contenttypes
from sapl.audiencia import models as audiencia from sapl.audiencia import models as audiencia
from sapl.base import models as base from sapl.base import models as base
from sapl.comissoes import models as comissoes from sapl.comissoes import models as comissoes
@ -11,6 +13,7 @@ from sapl.rules import SAPL_GROUP_GERAL, RP_ADD, __base__, __perms_publicas__, \
__listdetailchange__ __listdetailchange__
from sapl.sessao import models as sessao from sapl.sessao import models as sessao
rules_group_geral = { rules_group_geral = {
'group': SAPL_GROUP_GERAL, 'group': SAPL_GROUP_GERAL,
'rules': [ 'rules': [
@ -114,5 +117,8 @@ rules_group_geral = {
(audiencia.AudienciaPublica, __base__, __perms_publicas__), (audiencia.AudienciaPublica, __base__, __perms_publicas__),
(audiencia.TipoAudienciaPublica, __base__, __perms_publicas__), (audiencia.TipoAudienciaPublica, __base__, __perms_publicas__),
# permite consulta anônima pela api a lista de contenttypes
(contenttypes.ContentType, [], __perms_publicas__),
] ]
} }

Loading…
Cancel
Save