diff --git a/painel/migrations/0005_auto_20150909_1414.py b/painel/migrations/0005_auto_20150909_1414.py new file mode 100644 index 000000000..4e1254ec1 --- /dev/null +++ b/painel/migrations/0005_auto_20150909_1414.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('painel', '0004_auto_20150908_1858'), + ] + + operations = [ + migrations.RenameField( + model_name='cronometro', + old_name='data_painel', + new_name='data_cronometro', + ), + migrations.RemoveField( + model_name='cronometro', + name='time', + ), + ] diff --git a/painel/models.py b/painel/models.py index 525fcd97b..acf39338f 100644 --- a/painel/models.py +++ b/painel/models.py @@ -33,7 +33,7 @@ class Cronometro(models.Model): 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') + #time = models.FloatField(verbose_name='Start time', default=0) + data_cronometro = 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/urls.py b/painel/urls.py index 36e6bb312..77e9b7596 100644 --- a/painel/urls.py +++ b/painel/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.conf.urls import include, url -from .views import (controlador_painel, json_presenca, json_votacao, - painel_parlamentares_view, painel_view, +from .views import (controlador_painel, cronometro_painel_crud, json_presenca, + json_votacao, painel_parlamentares_view, painel_view, painel_votacao_view) urlpatterns = [ @@ -12,4 +12,6 @@ urlpatterns = [ url(r'^sistema/painel/votacao', painel_votacao_view), url(r'^sistema/painel/json_presenca', json_presenca, name='json_presenca'), url(r'^sistema/painel/json_votacao', json_votacao, name='json_votacao'), + url(r'^sistema/painel/cronometro', + include(cronometro_painel_crud.urls)), ] diff --git a/painel/views.py b/painel/views.py index eae59b1d2..d66707ff8 100644 --- a/painel/views.py +++ b/painel/views.py @@ -3,16 +3,27 @@ from datetime import date from django.core import serializers from django.http import HttpResponse, JsonResponse from django.shortcuts import render - +from django.utils.translation import ugettext_lazy as _ from painel.models import Painel from parlamentares.models import Filiacao +from sapl.crud import build_crud from sessao.models import (OrdemDia, PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, SessaoPlenariaPresenca, VotoParlamentar) +from .models import Cronometro + +cronometro_painel_crud = build_crud( + Cronometro, '', [ + + [_('Cronometro'), + [('status', 3), ('data_cronometro', 6), + ('tipo', 3)]], + ]) # REST WS + def controlador_painel(request): painel_created = Painel.objects.get_or_create(data_painel=date.today()) @@ -34,7 +45,9 @@ def controlador_painel(request): def cronometro_painel(request): - pass + print(request.POST) + + return HttpResponse({}) def painel_view(request): diff --git a/templates/sessao/painel.html b/templates/sessao/painel.html index 17e7d0b3f..bc930d732 100644 --- a/templates/sessao/painel.html +++ b/templates/sessao/painel.html @@ -99,6 +99,9 @@ $(function() { $('#discursoStart').click(function() { if($('#discursoStart').text() == 'Iniciar'){ + + $.post('/sistema/painel/cronometro', { tipo: 'Discurso', action: 'Start' } ); + $('#discursoReset').hide(); $('#discurso').runner('start'); $('#discursoStart').text('Parar'); @@ -107,6 +110,9 @@ $(function() { $('#ordemStart').prop('disabled', true); $('#ordemReset').prop('disabled', true); }else{ + + $.post('/sistema/painel/cronometro', { tipo: 'Discurso', action: 'Stop' } ); + $('#discursoReset').show(); $('#discurso').runner('stop'); $('#discursoStart').text('Iniciar'); @@ -118,6 +124,9 @@ $(function() { }); $('#discursoReset').click(function() { + + $.post('/sistema/painel/cronometro', { tipo: 'Discurso', action: 'Reset' } ); + $('#discurso').runner('stop'); $('#discurso').runner('reset'); }); @@ -134,6 +143,9 @@ $(function() { $('#aparteStart').click(function(){ if($('#aparteStart').text() == 'Iniciar'){ + + $.post('/sistema/painel/cronometro', { tipo: 'Aparte', action: 'Start' } ); + $('#aparteReset').hide(); $('#aparte').runner('start'); $('#aparteStart').text('Parar'); @@ -142,6 +154,9 @@ $(function() { $('#ordemStart').prop('disabled', true); $('#ordemReset').prop('disabled', true); }else{ + + $.post('/sistema/painel/cronometro', { tipo: 'Aparte', action: 'Stop' } ); + $('#aparteReset').show(); $('#aparte').runner('stop'); $('#aparteStart').text('Iniciar'); @@ -153,6 +168,9 @@ $(function() { }); $('#aparteReset').click(function() { + + $.post('/sistema/painel/cronometro', { tipo: 'Aparte', action: 'Reset' } ); + $('#aparte').runner('stop'); $('#aparte').runner('reset'); }); @@ -169,6 +187,9 @@ $(function() { $('#ordemStart').click(function() { if($('#ordemStart').text() == 'Iniciar'){ + + $.post('/sistema/painel/cronometro', { tipo: 'Ordem', action: 'Start' } ); + $('#ordemReset').hide(); $('#ordem').runner('start'); $('#ordemStart').text('Parar'); @@ -177,6 +198,9 @@ $(function() { $('#aparteStart').prop('disabled', true); $('#aparteReset').prop('disabled', true); }else{ + + $.post('/sistema/painel/cronometro', { tipo: 'Ordem', action: 'Stop' } ); + $('#ordemReset').show(); $('#ordem').runner('stop'); $('#ordemStart').text('Iniciar'); @@ -188,6 +212,9 @@ $(function() { }); $('#ordemReset').click(function() { + + $.post('/sistema/painel/cronometro', { tipo: 'Ordem', action: 'Reset' } ); + $('#ordem').runner('stop'); $('#ordem').runner('reset'); });