diff --git a/painel/migrations/0001_initial.py b/painel/migrations/0001_initial.py index 3fa9fdd97..ee7ee4836 100644 --- a/painel/migrations/0001_initial.py +++ b/painel/migrations/0001_initial.py @@ -13,20 +13,22 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Cronometro', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')), - ('start', models.PositiveIntegerField()), - ('reset', models.PositiveIntegerField()), - ('stop', models.PositiveIntegerField()), - ('tipo', models.CharField(choices=[('A', 'Aparte'), ('D', 'Discurso'), ('O', 'Ordem do dia')], max_length=1)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('start', models.PositiveIntegerField(verbose_name='Iniciar cronômetro')), + ('reset', models.PositiveIntegerField(verbose_name='Reiniciar cronômetro')), + ('stop', models.PositiveIntegerField(verbose_name='Parar cronômetro')), + ('data_painel', models.DateField(verbose_name='Data cronômetro')), + ('tipo', models.CharField(max_length=1, choices=[('A', 'Aparte'), ('D', 'Discurso'), ('O', 'Ordem do dia')], verbose_name='Tipo Cronômetro')), ], ), migrations.CreateModel( name='Painel', fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')), - ('abrir', models.PositiveIntegerField()), - ('fechar', models.PositiveIntegerField()), - ('mostrar', models.CharField(choices=[('C', 'Completo'), ('P', 'Parlamentares'), ('V', 'Votação'), ('M', 'Mensagem')], max_length=1)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('abrir', models.PositiveIntegerField(verbose_name='Abrir painel', default=0)), + ('fechar', models.PositiveIntegerField(verbose_name='Fechar painel', default=1)), + ('data_painel', models.DateField(verbose_name='Data painel')), + ('mostrar', models.CharField(max_length=1, choices=[('C', 'Completo'), ('P', 'Parlamentares'), ('V', 'Votação'), ('M', 'Mensagem')], default='C')), ], ), ] diff --git a/painel/migrations/0002_auto_20150908_1435.py b/painel/migrations/0002_auto_20150908_1435.py deleted file mode 100644 index 3c98a7701..000000000 --- a/painel/migrations/0002_auto_20150908_1435.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations -from django.utils.timezone import utc -import datetime - - -class Migration(migrations.Migration): - - dependencies = [ - ('painel', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='cronometro', - name='data', - field=models.DateField(null=True, verbose_name='Data cronômetro', auto_now_add=True), - ), - migrations.AddField( - model_name='painel', - name='data_painel', - field=models.DateField(default=datetime.datetime(2015, 9, 8, 17, 35, 48, 279510, tzinfo=utc), verbose_name='Data painel', auto_now_add=True), - preserve_default=False, - ), - migrations.AlterField( - model_name='cronometro', - name='reset', - field=models.PositiveIntegerField(verbose_name='Reiniciar cronômetro'), - ), - migrations.AlterField( - model_name='cronometro', - name='start', - field=models.PositiveIntegerField(verbose_name='Iniciar cronômetro'), - ), - migrations.AlterField( - model_name='cronometro', - name='stop', - field=models.PositiveIntegerField(verbose_name='Parar cronômetro'), - ), - migrations.AlterField( - model_name='cronometro', - name='tipo', - field=models.CharField(choices=[('A', 'Aparte'), ('D', 'Discurso'), ('O', 'Ordem do dia')], verbose_name='Tipo Cronômetro', max_length=1), - ), - migrations.AlterField( - model_name='painel', - name='abrir', - field=models.PositiveIntegerField(default=0, verbose_name='Abrir painel'), - ), - migrations.AlterField( - model_name='painel', - name='fechar', - field=models.PositiveIntegerField(default=1, verbose_name='Fechar painel'), - ), - migrations.AlterField( - model_name='painel', - name='mostrar', - field=models.CharField(default='C', choices=[('C', 'Completo'), ('P', 'Parlamentares'), ('V', 'Votação'), ('M', 'Mensagem')], max_length=1), - ), - ] diff --git a/painel/migrations/0002_auto_20150908_1818.py b/painel/migrations/0002_auto_20150908_1818.py new file mode 100644 index 000000000..9c4f07f65 --- /dev/null +++ b/painel/migrations/0002_auto_20150908_1818.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('painel', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='painel', + name='abrir', + ), + migrations.RemoveField( + model_name='painel', + name='fechar', + ), + migrations.AddField( + model_name='painel', + name='aberto', + field=models.BooleanField(verbose_name='Abrir painel', default=False), + ), + ] diff --git a/painel/migrations/0003_auto_20150908_1444.py b/painel/migrations/0003_auto_20150908_1444.py deleted file mode 100644 index 77e54a2b9..000000000 --- a/painel/migrations/0003_auto_20150908_1444.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations -from django.utils.timezone import utc -import datetime - - -class Migration(migrations.Migration): - - dependencies = [ - ('painel', '0002_auto_20150908_1435'), - ] - - operations = [ - migrations.AlterField( - model_name='cronometro', - name='data', - field=models.DateField(verbose_name='Data cronômetro', default=datetime.datetime(2015, 9, 8, 17, 44, 1, 708326, tzinfo=utc)), - preserve_default=False, - ), - migrations.AlterField( - model_name='painel', - name='data_painel', - field=models.DateField(verbose_name='Data painel'), - ), - ] diff --git a/painel/migrations/0003_cronometro_counter.py b/painel/migrations/0003_cronometro_counter.py new file mode 100644 index 000000000..a59968b8e --- /dev/null +++ b/painel/migrations/0003_cronometro_counter.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('painel', '0002_auto_20150908_1818'), + ] + + operations = [ + migrations.AddField( + model_name='cronometro', + name='counter', + field=models.PositiveIntegerField(default=0), + ), + ] diff --git a/painel/migrations/0004_auto_20150908_1858.py b/painel/migrations/0004_auto_20150908_1858.py new file mode 100644 index 000000000..388278b30 --- /dev/null +++ b/painel/migrations/0004_auto_20150908_1858.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('painel', '0003_cronometro_counter'), + ] + + operations = [ + migrations.RemoveField( + model_name='cronometro', + name='counter', + ), + migrations.RemoveField( + model_name='cronometro', + name='reset', + ), + migrations.RemoveField( + model_name='cronometro', + name='start', + ), + migrations.RemoveField( + model_name='cronometro', + name='stop', + ), + migrations.AddField( + model_name='cronometro', + name='status', + field=models.CharField(max_length=1, verbose_name='Status do cronômetro', choices=[('I', 'Start'), ('R', 'Reset'), ('S', 'Stop')], default='S'), + ), + migrations.AddField( + model_name='cronometro', + name='time', + field=models.FloatField(verbose_name='Start time', default=0), + ), + migrations.AlterField( + model_name='cronometro', + name='data_painel', + field=models.DateField(verbose_name='Data do cronômetro'), + ), + ] diff --git a/painel/models.py b/painel/models.py index aa9fb4856..525fcd97b 100644 --- a/painel/models.py +++ b/painel/models.py @@ -1,21 +1,6 @@ from django.db import models -class Cronometro(models.Model): - CRONOMETRO_TYPES = ( - ('A', 'Aparte'), - ('D', 'Discurso'), - ('O', 'Ordem do dia') - ) - - start = models.PositiveIntegerField(verbose_name='Iniciar cronômetro') - reset = models.PositiveIntegerField(verbose_name='Reiniciar cronômetro') - stop = models.PositiveIntegerField(verbose_name='Parar cronômetro') - data = models.DateField(verbose_name='Data cronômetro') - tipo = models.CharField( - max_length=1, choices=CRONOMETRO_TYPES, verbose_name='Tipo Cronômetro') - - class Painel(models.Model): PAINEL_TYPES = ( ('C', 'Completo'), @@ -24,10 +9,31 @@ class Painel(models.Model): ('M', 'Mensagem'), ) - abrir = models.PositiveIntegerField(verbose_name='Abrir painel', default=0) - fechar = models.PositiveIntegerField( - verbose_name='Fechar painel', default=1) + aberto = models.BooleanField(verbose_name='Abrir painel', default=False) data_painel = models.DateField(verbose_name='Data painel') mostrar = models.CharField(max_length=1, - choices=PAINEL_TYPES, - default='C') + choices=PAINEL_TYPES, default='C') + + +class Cronometro(models.Model): + CRONOMETRO_TYPES = ( + ('A', 'Aparte'), + ('D', 'Discurso'), + ('O', 'Ordem do dia') + ) + + CRONOMETRO_STATUS = ( + ('I', 'Start'), + ('R', 'Reset'), + ('S', 'Stop'), + ) + + status = models.CharField( + max_length=1, + verbose_name='Status do cronômetro', + choices=CRONOMETRO_STATUS, + default='S') + time = models.FloatField(verbose_name='Start time', default=0) + data_painel = models.DateField(verbose_name='Data do cronômetro') + tipo = models.CharField( + max_length=1, choices=CRONOMETRO_TYPES, verbose_name='Tipo Cronômetro') diff --git a/painel/views.py b/painel/views.py index 973d665f7..eae59b1d2 100644 --- a/painel/views.py +++ b/painel/views.py @@ -1,3 +1,5 @@ +from datetime import date + from django.core import serializers from django.http import HttpResponse, JsonResponse from django.shortcuts import render @@ -8,28 +10,33 @@ from sessao.models import (OrdemDia, PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, SessaoPlenariaPresenca, VotoParlamentar) -# UI views +# REST WS def controlador_painel(request): - painel = Painel.objects.update_or_create(abrir=0, fechar=1, mostrar='C')[0] + painel_created = Painel.objects.get_or_create(data_painel=date.today()) + painel = painel_created[0] if request.method == 'POST': if 'start-painel' in request.POST: - painel.abrir = 1 - painel.fechar = 0 + painel.aberto = True painel.save() elif 'stop-painel' in request.POST: - painel.abrir = 0 - painel.fechar = 1 + painel.aberto = False + painel.save() + elif 'save-painel' in request.POST: + painel.mostrar = request.POST['tipo_painel'] painel.save() - context = {'painel': painel} - print(painel.abrir) + context = {'painel': painel, 'PAINEL_TYPES': Painel.PAINEL_TYPES} return render(request, 'painel/controller.html', context) +def cronometro_painel(request): + pass + + def painel_view(request): context = {'head_title': 'Painel Plenário', 'title': '3a. Sessao Ordinária do Município XYZ'} diff --git a/sessao/views.py b/sessao/views.py index 0d7c67f68..5bd73dec6 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -2,8 +2,10 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from django.views.generic.edit import FormMixin from extra_views import InlineFormSetView + from parlamentares.models import Parlamentar from sapl.crud import build_crud + from .models import (ExpedienteMateria, ExpedienteSessao, OrdemDia, PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, SessaoPlenariaPresenca, TipoExpediente, diff --git a/templates/painel/controller.html b/templates/painel/controller.html index bd83cd5c4..7675303c1 100644 --- a/templates/painel/controller.html +++ b/templates/painel/controller.html @@ -1,10 +1,24 @@ {% extends 'base.html' %} {% load i18n %} {% block base_content %} -
+ +STATUS: +{% if painel.aberto %} +ABERTO +{% else %} +FECHADO +{% endif %} +