Browse Source

Fix #88 (Add DRF and Sessao Plenaria example)

pull/153/head
Edward Ribeiro 9 years ago
parent
commit
4e18fbf0d9
  1. 1
      requirements/requirements.txt
  2. 2
      sapl/settings.py
  3. 8
      sessao/serializers.py
  4. 7
      sessao/urls.py
  5. 8
      sessao/views.py

1
requirements/requirements.txt

@ -1,5 +1,6 @@
crispy-forms-foundation
Django<1.9
djangorestframework
django-admin-bootstrapped
django-bootstrap3
django-bower

2
sapl/settings.py

@ -39,6 +39,8 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
# sapl modules
'base',
'parlamentares',

8
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')

7
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<path>.*)$', '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)),

8
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
Loading…
Cancel
Save