Browse Source

Primeira versão do webservice de sessões plenárias. (#1080)

pull/1083/head
Edward 8 years ago
committed by GitHub
parent
commit
9c0343fe5e
  1. 23
      sapl/api/serializers.py
  2. 4
      sapl/api/urls.py
  3. 19
      sapl/api/views.py
  4. 19
      sapl/norma/migrations/0003_auto_20170510_1549.py
  5. 20
      sapl/sessao/migrations/0002_sessaoplenaria_interativa.py
  6. 3
      sapl/sessao/models.py
  7. 17
      sapl/sessao/serializers.py
  8. 5
      sapl/settings.py

23
sapl/api/serializers.py

@ -2,6 +2,7 @@ from rest_framework import serializers
from sapl.base.models import Autor
from sapl.materia.models import MateriaLegislativa
from sapl.sessao.models import SessaoPlenaria
class ChoiceSerializer(serializers.Serializer):
@ -52,3 +53,25 @@ class MateriaLegislativaSerializer(serializers.ModelSerializer):
class Meta:
model = MateriaLegislativa
fields = '__all__'
class SessaoPlenariaSerializer(serializers.ModelSerializer):
tipo = serializers.StringRelatedField(many=False)
sessao_legislativa = serializers.StringRelatedField(many=False)
legislatura = serializers.StringRelatedField(many=False)
class Meta:
model = SessaoPlenaria
fields = ('pk',
'tipo',
'sessao_legislativa',
'legislatura',
'data_inicio',
'hora_inicio',
'hora_fim',
'url_video',
'iniciada',
'finalizada',
'interativa'
)

4
sapl/api/urls.py

@ -3,7 +3,7 @@ from django.conf.urls import include, url
from rest_framework.routers import DefaultRouter
from sapl.api.views import (AutorListView, MateriaLegislativaViewSet,
ModelChoiceView)
ModelChoiceView, SessaoPlenariaViewSet)
from .apps import AppConfig
@ -12,9 +12,9 @@ app_name = AppConfig.name
router = DefaultRouter()
router.register(r'materia', MateriaLegislativaViewSet)
router.register(r'sessao-plenaria', SessaoPlenariaViewSet)
urlpatterns_router = router.urls
urlpatterns_api = [
url(r'^autor', AutorListView.as_view(), name='autor_list'),

19
sapl/api/views.py

@ -6,16 +6,19 @@ from rest_framework.filters import DjangoFilterBackend
from rest_framework.generics import ListAPIView
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
from rest_framework.permissions import (IsAuthenticated,
IsAuthenticatedOrReadOnly)
from rest_framework.viewsets import GenericViewSet
IsAuthenticatedOrReadOnly,
AllowAny)
from rest_framework.viewsets import GenericViewSet, ModelViewSet
from sapl.api.forms import AutorChoiceFilterSet
from sapl.api.serializers import (AutorChoiceSerializer, AutorSerializer,
ChoiceSerializer,
MateriaLegislativaSerializer,
ModelChoiceSerializer)
ModelChoiceSerializer,
SessaoPlenariaSerializer)
from sapl.base.models import Autor, TipoAutor
from sapl.materia.models import MateriaLegislativa
from sapl.sessao.models import SessaoPlenaria
from sapl.utils import SaplGenericRelation, sapl_logger
@ -203,3 +206,13 @@ class MateriaLegislativaViewSet(ListModelMixin,
queryset = MateriaLegislativa.objects.all()
filter_backends = (DjangoFilterBackend,)
filter_fields = ('numero', 'ano', 'tipo', )
class SessaoPlenariaViewSet(ListModelMixin,
RetrieveModelMixin,
GenericViewSet):
permission_classes = (AllowAny,)
serializer_class = SessaoPlenariaSerializer
queryset = SessaoPlenaria.objects.all()
filter_backends = (DjangoFilterBackend,)
filter_fields = ('data_inicio', 'data_fim', 'interativa')

19
sapl/norma/migrations/0003_auto_20170510_1549.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-05-10 15:49
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('norma', '0002_auto_20170403_1505'),
]
operations = [
migrations.AlterModelOptions(
name='assuntonorma',
options={'verbose_name': 'Assunto de Norma Jurídica', 'verbose_name_plural': 'Assuntos de Normas Jurídicas'},
),
]

20
sapl/sessao/migrations/0002_sessaoplenaria_interativa.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-05-10 15:49
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sessao', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='sessaoplenaria',
name='interativa',
field=models.NullBooleanField(choices=[(True, 'Sim'), (False, 'Não')], verbose_name='Sessão interativa'),
),
]

3
sapl/sessao/models.py

@ -156,6 +156,9 @@ class SessaoPlenaria(models.Model):
finalizada = models.NullBooleanField(blank=True,
choices=YES_NO_CHOICES,
verbose_name=_('Sessão finalizada?'))
interativa = models.NullBooleanField(blank=True,
choices=YES_NO_CHOICES,
verbose_name=_('Sessão interativa'))
class Meta:
verbose_name = _('Sessão Plenária')

17
sapl/sessao/serializers.py

@ -0,0 +1,17 @@
from rest_framework import serializers
from .models import SessaoPlenaria
class SessaoPlenariaSerializer(serializers.Serializer):
class Meta:
model = SessaoPlenaria
fields = ('tipo',
'sessao_legislativa',
'legislatura',
'data_inicio',
'hora_inicio',
'hora_fim',
'url_video',
'iniciada',
'finalizada'
)

5
sapl/settings.py

@ -111,10 +111,7 @@ MIDDLEWARE_CLASSES = (
REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": (
"rest_framework.renderers.JSONRenderer",
# "rest_framework.renderers.BrowsableAPIRenderer",
),
"UNICODE_JSON": False,
"DEFAULT_PARSER_CLASSES": (
"rest_framework.parsers.JSONParser",
),

Loading…
Cancel
Save