diff --git a/sapl/api/serializers.py b/sapl/api/serializers.py index a7ff559e3..21a48a848 100644 --- a/sapl/api/serializers.py +++ b/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' + ) diff --git a/sapl/api/urls.py b/sapl/api/urls.py index 195c7f84a..bf9c16c51 100644 --- a/sapl/api/urls.py +++ b/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'), diff --git a/sapl/api/views.py b/sapl/api/views.py index 71aa1b225..4a8341c52 100644 --- a/sapl/api/views.py +++ b/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') diff --git a/sapl/norma/migrations/0003_auto_20170510_1549.py b/sapl/norma/migrations/0003_auto_20170510_1549.py new file mode 100644 index 000000000..9cbd4962a --- /dev/null +++ b/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'}, + ), + ] diff --git a/sapl/sessao/migrations/0002_sessaoplenaria_interativa.py b/sapl/sessao/migrations/0002_sessaoplenaria_interativa.py new file mode 100644 index 000000000..9a868ce58 --- /dev/null +++ b/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'), + ), + ] diff --git a/sapl/sessao/models.py b/sapl/sessao/models.py index e308b4187..b76fac9f3 100644 --- a/sapl/sessao/models.py +++ b/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') diff --git a/sapl/sessao/serializers.py b/sapl/sessao/serializers.py new file mode 100644 index 000000000..6d6f4cd9b --- /dev/null +++ b/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' + ) diff --git a/sapl/settings.py b/sapl/settings.py index 3c757842e..ed49f5d4d 100644 --- a/sapl/settings.py +++ b/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", ),