Browse Source

2520 versionamento na api (#2522)

* altera script release.sh e settings.py

* altera api CasaLegislativa para possuir campo da versão do Sapl
pull/2527/head
Leandro Roberto Silva 6 years ago
committed by Edward
parent
commit
8909936faa
  1. 6
      release.sh
  2. 14
      sapl/api/serializers.py
  3. 7
      sapl/api/urls.py
  4. 2
      sapl/settings.py

6
release.sh

@ -14,14 +14,16 @@ function bump_version {
sed -e s/$VERSION/$NEXT_VERSION/g setup.py > tmp2
mv tmp2 setup.py
sed -e s/$VERSION/$NEXT_VERSION/g sapl/templates/base.html > tmp3
mv tmp3 sapl/templates/base.html
sed -e s/$VERSION/$NEXT_VERSION/g sapl/settings.py > tmp4
mv tmp4 sapl/settings.py
}
function commit_and_push {
echo "committing..."
git add docker-compose.yml setup.py sapl/templates/base.html
git add docker-compose.yml setup.py sapl/settings.py sapl/templates/base.html
git commit -m "Release: $NEXT_VERSION"
git tag $NEXT_VERSION

14
sapl/api/serializers.py

@ -1,6 +1,7 @@
from django.conf import settings
from rest_framework import serializers
from sapl.base.models import Autor
from sapl.base.models import Autor, CasaLegislativa
class ChoiceSerializer(serializers.Serializer):
@ -38,3 +39,14 @@ class AutorSerializer(serializers.ModelSerializer):
class Meta:
model = Autor
fields = '__all__'
class CasaLegislativaSerializer(serializers.ModelSerializer):
version = serializers.SerializerMethodField()
def get_version(self, obj):
return settings.SAPL_VERSION
class Meta:
model = CasaLegislativa
fields = '__all__'

7
sapl/api/urls.py

@ -40,7 +40,7 @@ schema_view = get_schema_view(
permission_classes=(permissions.AllowAny,),
)
urlpatterns_api = [
urlpatterns_api_doc = [
url(r'^docs/swagger(?P<format>\.json|\.yaml)$',
schema_view.without_ui(cache_timeout=0), name='schema-json'),
url(r'^docs/swagger/$',
@ -60,13 +60,16 @@ deprecated_urlpatterns_api = [
url(r'^model/(?P<content_type>\d+)/(?P<pk>\d*)$',
ModelChoiceView.as_view(), name='model_list'),
]
urlpatterns = [
url(r'^api/', include(deprecated_urlpatterns_api)),
url(r'^api/', include(urlpatterns_api)),
url(r'^api/', include(urlpatterns_api_doc)),
url(r'^api/', include(urlpatterns_router)),
# implementar caminho para autenticação
# https://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/
# url(r'^api/auth/', include('rest_framework.urls', namespace='rest_framework')),

2
sapl/settings.py

@ -41,6 +41,8 @@ ALLOWED_HOSTS = ['*']
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/login/?next='
SAPL_VERSION = '3.1.144'
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:

Loading…
Cancel
Save