diff --git a/requirements/requirements.txt b/requirements/requirements.txt index af7c3d8a2..eb951db1f 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,5 +1,6 @@ crispy-forms-foundation Django<1.9 +djangorestframework django-admin-bootstrapped django-bootstrap3 django-bower diff --git a/sapl/settings.py b/sapl/settings.py index c3971715d..06792d8d2 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -39,6 +39,8 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', + 'rest_framework', + # sapl modules 'base', 'parlamentares', diff --git a/sessao/serializers.py b/sessao/serializers.py new file mode 100644 index 000000000..cf3fedadd --- /dev/null +++ b/sessao/serializers.py @@ -0,0 +1,8 @@ +from rest_framework import serializers +from .models import SessaoPlenaria + +class SessaoPlenariaSerializer(serializers.ModelSerializer): + + class Meta: + model = SessaoPlenaria + fields = ('tipo', 'legislatura', 'sessao_legislativa') \ No newline at end of file diff --git a/sessao/urls.py b/sessao/urls.py index 0a3e74dd6..497823a28 100644 --- a/sessao/urls.py +++ b/sessao/urls.py @@ -10,7 +10,8 @@ from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView, OradorExpedienteView, PainelView, PautaSessaoDetailView, PautaSessaoListView, PresencaOrdemDiaView, PresencaView, ResumoView, - SessaoCadastroView, SessaoListView, VotacaoEditView, + SessaoCadastroView, SessaoListView, + SessaoPlenariaView, VotacaoEditView, VotacaoExpedienteEditView, VotacaoExpedienteView, VotacaoNominalEditView, VotacaoNominalExpedienteEditView, @@ -90,13 +91,17 @@ urlpatterns_sessao = sessao_crud.urlpatterns + [ PautaSessaoDetailView.as_view(), name='pauta_sessao_detail'), url(r'^cadastro$', SessaoCadastroView.as_view(), name='sessao_cadastro'), ] + sessao_urls = urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace +sessao_rest = [url(r'^sessao$', SessaoPlenariaView.as_view(), name='sessao_rest'),] + urlpatterns = [ url(r'^sessao/', include(urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace)), url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), + url(r'^rest/', include(sessao_rest)), url(r'^sistema/sessao-plenaria/tipo/', include(tipo_sessao_crud.urls)), url(r'^sistema/sessao-plenaria/tipo-resultado-votacao/', include(tipo_resultado_votacao_crud.urls)), diff --git a/sessao/views.py b/sessao/views.py index 0193d31a1..b18bfb598 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -12,7 +12,8 @@ from django.utils.html import strip_tags from django.utils.translation import ugettext_lazy as _ from django.views.generic import ListView from django.views.generic.edit import FormMixin - +from sessao.serializers import SessaoPlenariaSerializer +from rest_framework import generics import sapl from materia.models import Autoria, TipoMateriaLegislativa from parlamentares.models import Parlamentar @@ -2434,3 +2435,8 @@ class SessaoCadastroView(FormMixin, sessao_crud.CrudDetailView): def get_success_url(self): return reverse('sessaoplenaria:list_sessao') + + +class SessaoPlenariaView(generics.ListAPIView): + queryset = SessaoPlenaria.objects.select_related('sessao_legislativa').all() + serializer_class = SessaoPlenariaSerializer \ No newline at end of file