Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3279 leitura em bloco #3294

Open
wants to merge 8 commits into
base: 3.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sapl/sessao/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
OrdemDiaLeituraView,
retirar_leitura,
TransferenciaMateriasExpediente, TransferenciaMateriasOrdemDia,
filtra_materias_copia_sessao_ajax, verifica_materia_sessao_plenaria_ajax)
filtra_materias_copia_sessao_ajax, verifica_materia_sessao_plenaria_ajax,
LeituraEmBloco)


from .apps import AppConfig
Expand Down Expand Up @@ -145,6 +146,9 @@
url(r'^sessao/(?P<pk>\d+)/votacao_bloco_expediente$',
VotacaoEmBlocoExpediente.as_view(),
name='votacao_bloco_expediente'),
url(r'^sessao/(?P<pk>\d+)/leitura_em_bloco$',
LeituraEmBloco.as_view(),
name='leitura_em_bloco'),
url(r'^sessao/(?P<pk>\d+)/resumo$',
ResumoView.as_view(), name='resumo'),
url(r'^sessao/(?P<pk>\d+)/resumo_ata$',
Expand Down
48 changes: 48 additions & 0 deletions sapl/sessao/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4127,6 +4127,54 @@ def get_queryset(self):
retiradapauta=None)


class LeituraEmBloco(PermissionRequiredForAppCrudMixin, TemplateView):
app_label = AppConfig.label
logger = logging.getLogger(__name__)

def post(self, request, *args, **kwargs):

ulyssesBML marked this conversation as resolved.
Show resolved Hide resolved
origem = self.request.POST['origem']

if origem == 'ordem':
model = OrdemDia
presenca_model = PresencaOrdemDia
elif origem == 'expediente':
model = ExpedienteMateria
presenca_model = SessaoPlenariaPresenca

spk = SessaoPlenaria.objects.get(pk=kwargs['pk'])
if not verifica_presenca(request, presenca_model, spk, True):
return HttpResponseRedirect(self.get_success_url())

leituras = model.objects.filter(
id__in=request.POST.getlist('marcadas_4'))

lista_registro_leitura = []
for ordem in leituras:
ordem.resultado = "Matéria lida em Bloco"
ordem.votacao_aberta = False
ordem.registro_aberto = False
if origem == 'ordem':
rl = RegistroLeitura(materia=ordem.materia,ordem=ordem,user=request.user,ip=get_client_ip(request))
elif origem == 'expediente':
rl = RegistroLeitura(materia=ordem.materia,expediente=ordem,user=request.user,ip=get_client_ip(request))
rl.observacao = self.request.POST.get('observacao',"")
lista_registro_leitura.append(rl)

RegistroLeitura.objects.bulk_create(lista_registro_leitura)
model.objects.bulk_update(leituras, ['resultado','votacao_aberta','registro_aberto'])


return HttpResponseRedirect(self.get_success_url())

def get_success_url(self):
if self.request.POST['origem'] == 'ordem':
return reverse('sapl.sessao:ordemdia_list',
kwargs={'pk': self.kwargs['pk']})
else:
return reverse('sapl.sessao:expedientemateria_list',
kwargs={'pk': self.kwargs['pk']})

class VotacaoEmBlocoSimbolicaView(PermissionRequiredForAppCrudMixin, TemplateView):

"""
Expand Down
67 changes: 52 additions & 15 deletions sapl/templates/sessao/votacao/votacao_bloco.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</br>
<input type="radio" name="tipo_votacao" id="tipo_votacao_2" value="2" onchange="alteraTipoVotacao()" > <label for="tipo">Nominal</label>
</br>
<input type="radio" name="tipo_votacao" id="tipo_votacao_4" value="4" onchange="alteraTipoVotacao()" > <label for="tipo">Leitura</label><!--value=3 é pra votação secreta que não pode ser feita em bloco-->
</fieldset>
</td>
</tr>
Expand All @@ -43,8 +44,8 @@ <h3 id='frase_selecione'>{% if expediente %} Selecione o(s) expediente(s) deseja
</div>

{% for o in object_list %}
{% if o.tipo_votacao == 1 or o.tipo_votacao == 2 %}
<tr class="{% if o.tipo_votacao == 1 %}Simbolica{% else %}Nominal{% endif %}" {% if o.tipo_votacao == 2 %} style="display:none;" {% endif %}>
{% if o.tipo_votacao == 1 or o.tipo_votacao == 2 or o.tipo_votacao == 4 %}
<tr class="{% if o.tipo_votacao == 1 %} Simbolica {% elif o.tipo_votacao == 2 %}Nominal{% else %}Leitura{% endif %}" {% if o.tipo_votacao > 1 %} style="display:none;" {% endif %}>
<td>
<input type="checkbox" name="marcadas_{{o.tipo_votacao}}" id="{{o.id}}" value="{{o.id}}" {% if check %} checked {% endif %}>
<strong><a href="{% url 'sapl.materia:materialegislativa_detail' o.materia.id %}">{{o.materia.tipo.sigla}} {{o.materia.numero}}/{{o.materia.ano}} - {{o.materia.tipo}}</strong></a></br>
Expand Down Expand Up @@ -98,7 +99,30 @@ <h3>{% if expediente %} Nenhuma matéria do expediente aberta. {% else %} Nenhum
<a href="{% url 'sapl.sessao:ordemdia_list' pk %}" class="btn btn-warning mb-3" id="but_cancel">Voltar</a>
<input type="hidden" id="origem" name="origem" value="ordem">
{% endif %}
<input type="submit" value="Registrar votação" class="btn btn-primary mb-3 float-right" id="but_reg">
<a onclick="submit_button()" class="btn btn-primary mb-3 float-right" id="but_reg">Registrar votação</a>

<div class="modal fade" id="leituraModal" tabindex="-1" role="dialog" aria-labelledby="leituraModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="leituraModalLabel">Observação da Leitura</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="message-text" class="col-form-label">Observação:</label>
<textarea class="form-control" id="observacao" name="observacao"></textarea>
</div>
</div>
<div class="modal-footer">
<a type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</a>
<input type="submit" class="btn btn-primary mb-3 float-right" value="Salvar">
</div>
</div>
</div>
</div>
</form>
{% endif %}

Expand All @@ -118,22 +142,20 @@ <h3>{% if expediente %} Nenhuma matéria do expediente aberta. {% else %} Nenhum

<script language="JavaScript">
function checkAll(elem) {
let checkboxes = document.getElementsByName('marcadas_1');
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox')
checkboxes[i].checked = elem.checked;
}

checkboxes = document.getElementsByName('marcadas_2');
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox')
checkboxes[i].checked = elem.checked;
let checkbox_types = ['marcadas_1', 'marcadas_2', 'marcadas_4']
for (t in checkbox_types){
let checkboxes = document.getElementsByName(checkbox_types[t]);
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox')
checkboxes[i].checked = elem.checked;
}
}
}

function alteraTipoVotacao() {
$(".Simbolica").toggle();
$(".Nominal").toggle();
$(".Leitura").toggle();

checa_tipo_votacao();
}
Expand All @@ -156,13 +178,28 @@ <h3>{% if expediente %} Nenhuma matéria do expediente aberta. {% else %} Nenhum
document.getElementById('but_reg').style.display = '';
document.getElementById('nenhuma_mat').style.display = 'none';
}


$("#but_reg").text("Registrar Votação")
if(tipo_votacao == "1"){
$('#form').attr("action", "{% url 'sapl.sessao:votacaoblocosimb' pk %}")
}
else{
else if(tipo_votacao == "2"){
$('#form').attr("action", "{% url 'sapl.sessao:votacaobloconom' pk %}")
}
else{
$("#but_reg").text("Registrar Leitura")
$('#form').attr("action", "{% url 'sapl.sessao:leitura_em_bloco' pk %}")
}
}

function submit_button(){
var radioValue = $("input[name='tipo_votacao']:checked").val();
if (radioValue == 4){
$('#leituraModal').modal('show')
}
else{
$("#form").submit()
}
}
</script>
{% endblock extra_js%}