From 4f6f8fed5450ba6125f984416a747787cc2042b4 Mon Sep 17 00:00:00 2001 From: Edward <9326037+edwardoliveira@users.noreply.github.com> Date: Thu, 25 Mar 2021 11:07:31 -0300 Subject: [PATCH] Atualiza drf e drf-yasg (#3378) * Atualiza drf e drf-yasg * Adequa serializers de sapl.api ao drf-yasg 1.20 Co-authored-by: eribeiro Co-authored-by: Leandro Roberto --- requirements/requirements.txt | 4 ++-- sapl/api/views.py | 12 +++++++----- sapl/settings.py | 3 --- setup.py | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 836fe377a..98a0715a4 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,7 +1,7 @@ django==2.2.18 django-haystack==2.8.1 django-filter==2.0.0 -djangorestframework==3.9.1 +djangorestframework==3.11.2 dj-database-url==0.5.0 django-braces==1.14.0 django-crispy-forms==1.7.2 @@ -14,7 +14,7 @@ django-speedinfo==1.4.0 django-extensions==2.1.4 django-image-cropping==1.2 django-webpack-loader==0.6.0 -drf-yasg==1.13.0 +drf-yasg==1.20.0 easy-thumbnails==2.5 python-decouple==3.1 psycopg2-binary==2.8.6 diff --git a/sapl/api/views.py b/sapl/api/views.py index 6d506e6bf..f4e853ccd 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -62,12 +62,11 @@ class BusinessRulesNotImplementedMixin: raise Exception(_("DELETE Delete não implementado")) -class SaplApiViewSet(ModelViewSet): - filter_backends = (DjangoFilterBackend,) - - class SaplApiViewSetConstrutor(): + class SaplApiViewSet(ModelViewSet): + filter_backends = (DjangoFilterBackend,) + _built_sets = {} @classonlymethod @@ -124,6 +123,9 @@ class SaplApiViewSetConstrutor(): __str__ = SerializerMethodField() class Meta(_meta_serializer): + if not hasattr(_meta_serializer, 'ref_name'): + ref_name = None + if not hasattr(_meta_serializer, 'model'): model = _model @@ -152,7 +154,7 @@ class SaplApiViewSetConstrutor(): model = _model # Define uma classe padrão ModelViewSet de DRF - class ModelSaplViewSet(SaplApiViewSet): + class ModelSaplViewSet(SaplApiViewSetConstrutor.SaplApiViewSet): queryset = _model.objects.all() # Utiliza o filtro customizado pela classe diff --git a/sapl/settings.py b/sapl/settings.py index 1e577eb20..da424db68 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -65,9 +65,7 @@ SAPL_APPS = ( 'sapl.redireciona_urls', 'sapl.compilacao', 'sapl.api', - 'sapl.rules' - ) INSTALLED_APPS = ( @@ -84,7 +82,6 @@ INSTALLED_APPS = ( 'floppyforms', 'drf_yasg', - # 'rest_framework_swagger', 'rest_framework', 'rest_framework.authtoken', 'django_filters', diff --git a/setup.py b/setup.py index 99b6a28ca..d45823d43 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ install_requires = [ 'django>=1.11.19,<2.0', 'django-haystack==2.8.1', 'django-filter==2.0.0', - 'djangorestframework==3.9.1', + 'djangorestframework==3.11.2', 'dj-database-url==0.5.0', 'django-braces==1.9.0', 'django-crispy-forms==1.7.2', @@ -25,7 +25,7 @@ install_requires = [ 'django-extensions==2.1.4', 'django-image-cropping==1.2.0', 'django-webpack-loader==0.6.0', - 'drf-yasg==1.13.0', + 'drf-yasg==1.20.0', 'easy-thumbnails==2.5', 'python-decouple==3.1', 'psycopg2-binary==2.7.6.1',