Browse Source

Add view for painel cronometro

pull/7/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
855c38f38f
  1. 23
      painel/migrations/0005_auto_20150909_1414.py
  2. 4
      painel/models.py
  3. 8
      painel/urls.py
  4. 17
      painel/views.py
  5. 27
      templates/sessao/painel.html

23
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',
),
]

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

8
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)),
]

17
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):

27
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');
});

Loading…
Cancel
Save