Browse Source

Merge

pull/760/head
Eduardo Calil 9 years ago
parent
commit
603fcb0978
  1. 67
      sapl/painel/views.py
  2. 8
      sapl/sessao/views.py

67
sapl/painel/views.py

@ -82,21 +82,13 @@ def get_cronometro_status(request, name):
def get_materia_aberta(pk): def get_materia_aberta(pk):
try: return OrdemDia.objects.filter(
materia = OrdemDia.objects.filter(
sessao_plenaria_id=pk, votacao_aberta=True).last() sessao_plenaria_id=pk, votacao_aberta=True).last()
return materia
except ObjectDoesNotExist:
return None
def get_last_materia(pk): def get_last_materia(pk):
try: return OrdemDia.objects.filter(
materia = OrdemDia.objects.filter(
sessao_plenaria_id=pk).last() sessao_plenaria_id=pk).last()
return materia
except ObjectDoesNotExist:
return None
def get_presentes(pk, response, materia): def get_presentes(pk, response, materia):
@ -136,11 +128,14 @@ def get_presentes(pk, response, materia):
num_presentes_ordem_dia = len(presentes_ordem_dia) num_presentes_ordem_dia = len(presentes_ordem_dia)
if materia.tipo_votacao == 1: if materia.tipo_votacao == 1:
tipo_votacao = 'Simbólica' tipo_votacao = str(_('Simbólica'))
response = get_votos(response, materia)
elif materia.tipo_votacao == 2: elif materia.tipo_votacao == 2:
tipo_votacao = 'Nominal' tipo_votacao = 'Nominal'
response = get_votos_nominal(response, materia)
elif materia.tipo_votacao == 3: elif materia.tipo_votacao == 3:
tipo_votacao = 'Secreta' tipo_votacao = 'Secreta'
response = get_votos(response, materia)
response.update({ response.update({
'presentes_ordem_dia': presentes_ordem_dia, 'presentes_ordem_dia': presentes_ordem_dia,
@ -149,10 +144,6 @@ def get_presentes(pk, response, materia):
'num_presentes_sessao_plenaria': num_presentes_sessao_plen, 'num_presentes_sessao_plenaria': num_presentes_sessao_plen,
'status_painel': 'ABERTO', 'status_painel': 'ABERTO',
'msg_painel': str(_('Votação aberta!')), 'msg_painel': str(_('Votação aberta!')),
'numero_votos_sim': 0,
'numero_votos_nao': 0,
'numero_abstencoes': 0,
'total_votos': 0,
'tipo_resultado': tipo_votacao, 'tipo_resultado': tipo_votacao,
'observacao_materia': materia.observacao, 'observacao_materia': materia.observacao,
'materia_legislativa_texto': str(materia.materia)}) 'materia_legislativa_texto': str(materia.materia)})
@ -164,21 +155,13 @@ def get_presentes(pk, response, materia):
def get_materia_expediente_aberta(pk): def get_materia_expediente_aberta(pk):
try: return ExpedienteMateria.objects.filter(
materia = ExpedienteMateria.objects.filter(
sessao_plenaria_id=pk, votacao_aberta=True).last() sessao_plenaria_id=pk, votacao_aberta=True).last()
return materia
except ObjectDoesNotExist:
return None
def get_last_materia_expediente(pk): def get_last_materia_expediente(pk):
try: return ExpedienteMateria.objects.filter(
materia = ExpedienteMateria.objects.filter(
sessao_plenaria_id=pk).last() sessao_plenaria_id=pk).last()
return materia
except ObjectDoesNotExist:
return None
def get_presentes_expediente(pk, response, materia): def get_presentes_expediente(pk, response, materia):
@ -219,10 +202,14 @@ def get_presentes_expediente(pk, response, materia):
if materia.tipo_votacao == 1: if materia.tipo_votacao == 1:
tipo_votacao = 'Simbólica' tipo_votacao = 'Simbólica'
response = get_votos(response, materia)
elif materia.tipo_votacao == 2: elif materia.tipo_votacao == 2:
tipo_votacao = 'Nominal' tipo_votacao = 'Nominal'
response = get_votos_nominal(response, materia)
elif materia.tipo_votacao == 3: elif materia.tipo_votacao == 3:
tipo_votacao = 'Secreta' tipo_votacao = 'Secreta'
response = get_votos(response, materia)
response.update({ response.update({
'presentes_expediente': presentes_expediente, 'presentes_expediente': presentes_expediente,
'num_presentes_expediente': num_presentes_expediente, 'num_presentes_expediente': num_presentes_expediente,
@ -230,10 +217,6 @@ def get_presentes_expediente(pk, response, materia):
'num_presentes_sessao_plenaria': num_presentes_sessao_plen, 'num_presentes_sessao_plenaria': num_presentes_sessao_plen,
'status_painel': str(_('ABERTO')), 'status_painel': str(_('ABERTO')),
'msg_painel': str(_('Votação aberta!')), 'msg_painel': str(_('Votação aberta!')),
'numero_votos_sim': 0,
'numero_votos_nao': 0,
'numero_abstencoes': 0,
'total_votos': 0,
'tipo_resultado': tipo_votacao, 'tipo_resultado': tipo_votacao,
'observacao_materia': materia.observacao, 'observacao_materia': materia.observacao,
'materia_legislativa_texto': str(materia.materia)}) 'materia_legislativa_texto': str(materia.materia)})
@ -262,6 +245,8 @@ def get_votos(response, materia):
registro = RegistroVotacao.objects.filter( registro = RegistroVotacao.objects.filter(
ordem=materia, materia=materia.materia).last() ordem=materia, materia=materia.materia).last()
if registro:
total = (registro.numero_votos_sim + total = (registro.numero_votos_sim +
registro.numero_votos_nao + registro.numero_votos_nao +
registro.numero_abstencoes) registro.numero_abstencoes)
@ -273,6 +258,15 @@ def get_votos(response, materia):
'tipo_votacao': tipo_votacao, 'tipo_votacao': tipo_votacao,
'tipo_resultado': registro.tipo_resultado_votacao.nome, 'tipo_resultado': registro.tipo_resultado_votacao.nome,
}) })
else:
response.update({
'numero_votos_sim': 0,
'numero_votos_nao': 0,
'numero_abstencoes': 0,
'total_votos': 0,
'tipo_votacao': tipo_votacao,
'tipo_resultado': 'Ainda não foi votada.',
})
return response return response
@ -286,9 +280,21 @@ def get_votos_nominal(response, materia):
elif materia.tipo_votacao == 3: elif materia.tipo_votacao == 3:
tipo_votacao = 'Secreta' tipo_votacao = 'Secreta'
try:
registro = RegistroVotacao.objects.get( registro = RegistroVotacao.objects.get(
ordem=materia, materia=materia.materia) ordem=materia, materia=materia.materia)
except ObjectDoesNotExist:
response.update({
'numero_votos_sim': 0,
'numero_votos_nao': 0,
'numero_abstencoes': 0,
'total_votos': 0,
'tipo_votacao': tipo_votacao,
'tipo_resultado': 'Não foi votado ainda',
'votos': None
})
else:
votos_parlamentares = VotoParlamentar.objects.filter( votos_parlamentares = VotoParlamentar.objects.filter(
votacao_id=registro.id) votacao_id=registro.id)
@ -312,7 +318,8 @@ def get_votos_nominal(response, materia):
votos.update({v.parlamentar.id: { votos.update({v.parlamentar.id: {
'parlamentar': v.parlamentar.nome_parlamentar, 'parlamentar': v.parlamentar.nome_parlamentar,
'voto': str(v.voto), 'voto': str(v.voto),
'partido': parlamentar_partido[v.parlamentar.nome_parlamentar] 'partido': parlamentar_partido[
v.parlamentar.nome_parlamentar]
}}) }})
total = (registro.numero_votos_sim + total = (registro.numero_votos_sim +

8
sapl/sessao/views.py

@ -2,7 +2,8 @@ from datetime import datetime
from re import sub from re import sub
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import (ObjectDoesNotExist, MultipleObjectsReturned,
ValidationError)
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
from django.http import JsonResponse from django.http import JsonResponse
@ -1855,9 +1856,14 @@ class VotacaoExpedienteEditView(SessaoPermissionMixin):
'ementa': expediente.observacao} 'ementa': expediente.observacao}
context.update({'materia': materia}) context.update({'materia': materia})
try:
votacao = RegistroVotacao.objects.get( votacao = RegistroVotacao.objects.get(
materia_id=materia_id, materia_id=materia_id,
expediente_id=expediente_id) expediente_id=expediente_id)
except MultipleObjectsReturned:
votacao = RegistroVotacao.objects.get(
materia_id=materia_id,
expediente_id=expediente_id).last()
votacao_existente = {'observacao': sub( votacao_existente = {'observacao': sub(
' ', ' ', strip_tags(votacao.observacao)), ' ', ' ', strip_tags(votacao.observacao)),
'tipo_resultado': 'tipo_resultado':

Loading…
Cancel
Save