Browse Source

Add model and new template to painel

pull/7/head
Edward Ribeiro 9 years ago
parent
commit
bb3fe7e8aa
  1. 32
      painel/migrations/0001_initial.py
  2. 62
      painel/migrations/0002_auto_20150908_1435.py
  3. 27
      painel/migrations/0003_auto_20150908_1444.py
  4. 34
      painel/models.py
  5. 7
      painel/urls.py
  6. 53
      painel/views.py
  7. 1
      requirements/dev-requirements.txt
  8. 13
      scripts/voto_parlamentar.sql
  9. 45
      templates/painel/controlador.html
  10. 10
      templates/painel/controller.html

32
painel/migrations/0001_initial.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
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)),
],
),
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)),
],
),
]

62
painel/migrations/0002_auto_20150908_1435.py

@ -0,0 +1,62 @@
# -*- 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),
),
]

27
painel/migrations/0003_auto_20150908_1444.py

@ -0,0 +1,27 @@
# -*- 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'),
),
]

34
painel/models.py

@ -1,3 +1,33 @@
# from django.db import models from django.db import models
# Create your models here.
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'),
('P', 'Parlamentares'),
('V', 'Votação'),
('M', 'Mensagem'),
)
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=PAINEL_TYPES,
default='C')

7
painel/urls.py

@ -1,10 +1,13 @@
from django.conf.urls import url from django.conf.urls import url
from .views import (json_presenca, json_votacao, painel_parlamentares_view, from .views import (controlador_painel, json_presenca, json_votacao,
painel_view, painel_votacao_view) painel_parlamentares_view, painel_view,
painel_votacao_view)
urlpatterns = [ urlpatterns = [
url(r'^sistema/painel$', painel_view), url(r'^sistema/painel$', painel_view),
url(r'^sistema/painel/controlador',
controlador_painel, name='controlador_painel'),
url(r'^sistema/painel/parlamentares', painel_parlamentares_view), url(r'^sistema/painel/parlamentares', painel_parlamentares_view),
url(r'^sistema/painel/votacao', painel_votacao_view), url(r'^sistema/painel/votacao', painel_votacao_view),
url(r'^sistema/painel/json_presenca', json_presenca, name='json_presenca'), url(r'^sistema/painel/json_presenca', json_presenca, name='json_presenca'),

53
painel/views.py

@ -1,16 +1,51 @@
from django.core import serializers from django.core import serializers
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from django.shortcuts import render from django.shortcuts import render
from painel.models import Painel
from parlamentares.models import Filiacao from parlamentares.models import Filiacao
from sessao.models import (OrdemDia, PresencaOrdemDia, RegistroVotacao, from sessao.models import (OrdemDia, PresencaOrdemDia, RegistroVotacao,
SessaoPlenaria, SessaoPlenariaPresenca, SessaoPlenaria, SessaoPlenariaPresenca,
VotoParlamentar) VotoParlamentar)
# UI views
def controlador_painel(request):
painel = Painel.objects.update_or_create(abrir=0, fechar=1, mostrar='C')[0]
if request.method == 'POST':
if 'start-painel' in request.POST:
painel.abrir = 1
painel.fechar = 0
painel.save()
elif 'stop-painel' in request.POST:
painel.abrir = 0
painel.fechar = 1
painel.save()
context = {'painel': painel}
print(painel.abrir)
return render(request, 'painel/controller.html', context)
def painel_view(request):
context = {'head_title': 'Painel Plenário',
'title': '3a. Sessao Ordinária do Município XYZ'}
return render(request, 'painel/index.html', {'context': context})
def painel_parlamentares_view(request):
return render(request, 'painel/parlamentares.html')
def painel_votacao_view(request):
return render(request, 'painel/votacao.html')
# REST web services # REST web services
def json_presenca(request): def json_presenca(request):
presencas = PresencaOrdemDia.objects.filter(sessao_plenaria_id=50) presencas = PresencaOrdemDia.objects.filter(sessao_plenaria_id=50)
parlamentares = [] parlamentares = []
@ -93,19 +128,3 @@ def json_votacao(request):
"presentes_sessao_plenaria": presentes_sessao_plenaria, "presentes_sessao_plenaria": presentes_sessao_plenaria,
} }
return JsonResponse(votacao_json) return JsonResponse(votacao_json)
# UI views
def painel_view(request):
context = {'head_title': 'Painel Plenário',
'title': '3a. Sessao Ordinária do Município XYZ'}
return render(request, 'painel/index.html', {'context': context})
def painel_parlamentares_view(request):
return render(request, 'painel/parlamentares.html')
def painel_votacao_view(request):
return render(request, 'painel/votacao.html')

1
requirements/dev-requirements.txt

@ -5,5 +5,6 @@ django-extensions
flake8 flake8
ipdb ipdb
isort isort
autopep8
pygraphviz==1.3rc2 pygraphviz==1.3rc2
pytest-ipdb==0.1-prerelease2 pytest-ipdb==0.1-prerelease2

13
scripts/voto_parlamentar.sql

@ -0,0 +1,13 @@

INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (1, 21, 'S', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (2, 23, 'S', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (3, 33, 'S', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (4, 112, 'S', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (5, 117, 'S', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (9, 116, 'N', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (6, 120, 'N', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (7, 121, 'N', 83);
INSERT INTO sessao_votoparlamentar (id, parlamentar_id, voto, votacao_id) values (8, 122, 'N', 83);
SELECT * FROM sessao_votoparlamentar;

45
templates/painel/controlador.html

@ -1,45 +0,0 @@
{% load i18n %}
{% load staticfiles %}
<!DOCTYPE HTML>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<meta charset="UTF-8">
<!-- TODO: does it need this head_title here? -->
<title>{% block head_title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="{% static 'foundation/js/vendor/jquery.js' %}"></script>
<STYLE type="text/css">
@media screen {
body {font-size: medium; color: white; line-height: 1em; background: black;}
}
</STYLE>
</head>
<body>
STATUS SESSÃO:<br/>
<button id="open-votacao">Iniciar Votação</button>
<button id="close-votacao">Fechar Votação</button>
<br/>
CRONÔMETROS:<br/>
<button id="init-stopwatch-discurso">Iniciar Cronômetro discurso</button>
<button id="init-stopwatch-aparte">Iniciar Cronômetro aparte</button>
<button id="init-stopwatch-questaoordem">Iniciar Cronômetro Questão de Ordem</button>
<br/>
<button id="stop-stopwatch-discurso">Parar Cronômetro discurso</button>
<button id="stop-stopwatch-aparte">Parar Cronômetro aparte</button>
<button id="stop-stopwatch-questaoordem">Parar Cronômetro Questão de Ordem</button>
<br/>
<button id="reset-stopwatch-discurso">Reiniciar Cronômetro discurso</button>
<button id="reset-stopwatch-aparte">Reiniciar Cronômetro aparte</button>
<button id="reset-stopwatch-questaoordem">Reiniciar Cronômetro Questão de Ordem</button>
<br/>
</body>
</html>

10
templates/painel/controller.html

@ -0,0 +1,10 @@
{% extends 'base.html' %}
{% load i18n %}
{% block base_content %}
<form method="post">
{% csrf_token %}
{{ painel.fechar }}<br/>
<input type="submit" name="start-painel" value="Abrir Painel">
<input type="submit" name="stop-painel" value="Fechar Painel">
</form>
{% endblock %}
Loading…
Cancel
Save