Browse Source

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 <edwardr@senado.leg.br>
Co-authored-by: Leandro Roberto <leandroroberto.br@gmail.com>
pull/3383/head
Edward 4 years ago
committed by GitHub
parent
commit
4f6f8fed54
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      requirements/requirements.txt
  2. 10
      sapl/api/views.py
  3. 3
      sapl/settings.py
  4. 4
      setup.py

4
requirements/requirements.txt

@ -1,7 +1,7 @@
django==2.2.18 django==2.2.18
django-haystack==2.8.1 django-haystack==2.8.1
django-filter==2.0.0 django-filter==2.0.0
djangorestframework==3.9.1 djangorestframework==3.11.2
dj-database-url==0.5.0 dj-database-url==0.5.0
django-braces==1.14.0 django-braces==1.14.0
django-crispy-forms==1.7.2 django-crispy-forms==1.7.2
@ -14,7 +14,7 @@ django-speedinfo==1.4.0
django-extensions==2.1.4 django-extensions==2.1.4
django-image-cropping==1.2 django-image-cropping==1.2
django-webpack-loader==0.6.0 django-webpack-loader==0.6.0
drf-yasg==1.13.0 drf-yasg==1.20.0
easy-thumbnails==2.5 easy-thumbnails==2.5
python-decouple==3.1 python-decouple==3.1
psycopg2-binary==2.8.6 psycopg2-binary==2.8.6

10
sapl/api/views.py

@ -62,12 +62,11 @@ class BusinessRulesNotImplementedMixin:
raise Exception(_("DELETE Delete não implementado")) raise Exception(_("DELETE Delete não implementado"))
class SaplApiViewSetConstrutor():
class SaplApiViewSet(ModelViewSet): class SaplApiViewSet(ModelViewSet):
filter_backends = (DjangoFilterBackend,) filter_backends = (DjangoFilterBackend,)
class SaplApiViewSetConstrutor():
_built_sets = {} _built_sets = {}
@classonlymethod @classonlymethod
@ -124,6 +123,9 @@ class SaplApiViewSetConstrutor():
__str__ = SerializerMethodField() __str__ = SerializerMethodField()
class Meta(_meta_serializer): class Meta(_meta_serializer):
if not hasattr(_meta_serializer, 'ref_name'):
ref_name = None
if not hasattr(_meta_serializer, 'model'): if not hasattr(_meta_serializer, 'model'):
model = _model model = _model
@ -152,7 +154,7 @@ class SaplApiViewSetConstrutor():
model = _model model = _model
# Define uma classe padrão ModelViewSet de DRF # Define uma classe padrão ModelViewSet de DRF
class ModelSaplViewSet(SaplApiViewSet): class ModelSaplViewSet(SaplApiViewSetConstrutor.SaplApiViewSet):
queryset = _model.objects.all() queryset = _model.objects.all()
# Utiliza o filtro customizado pela classe # Utiliza o filtro customizado pela classe

3
sapl/settings.py

@ -65,9 +65,7 @@ SAPL_APPS = (
'sapl.redireciona_urls', 'sapl.redireciona_urls',
'sapl.compilacao', 'sapl.compilacao',
'sapl.api', 'sapl.api',
'sapl.rules' 'sapl.rules'
) )
INSTALLED_APPS = ( INSTALLED_APPS = (
@ -84,7 +82,6 @@ INSTALLED_APPS = (
'floppyforms', 'floppyforms',
'drf_yasg', 'drf_yasg',
# 'rest_framework_swagger',
'rest_framework', 'rest_framework',
'rest_framework.authtoken', 'rest_framework.authtoken',
'django_filters', 'django_filters',

4
setup.py

@ -12,7 +12,7 @@ install_requires = [
'django>=1.11.19,<2.0', 'django>=1.11.19,<2.0',
'django-haystack==2.8.1', 'django-haystack==2.8.1',
'django-filter==2.0.0', 'django-filter==2.0.0',
'djangorestframework==3.9.1', 'djangorestframework==3.11.2',
'dj-database-url==0.5.0', 'dj-database-url==0.5.0',
'django-braces==1.9.0', 'django-braces==1.9.0',
'django-crispy-forms==1.7.2', 'django-crispy-forms==1.7.2',
@ -25,7 +25,7 @@ install_requires = [
'django-extensions==2.1.4', 'django-extensions==2.1.4',
'django-image-cropping==1.2.0', 'django-image-cropping==1.2.0',
'django-webpack-loader==0.6.0', 'django-webpack-loader==0.6.0',
'drf-yasg==1.13.0', 'drf-yasg==1.20.0',
'easy-thumbnails==2.5', 'easy-thumbnails==2.5',
'python-decouple==3.1', 'python-decouple==3.1',
'psycopg2-binary==2.7.6.1', 'psycopg2-binary==2.7.6.1',

Loading…
Cancel
Save