|
|
@ -29,7 +29,7 @@ from sapl.materia.models import (Autoria, DocumentoAcessorio, |
|
|
from sapl.materia.views import MateriaLegislativaPesquisaView |
|
|
from sapl.materia.views import MateriaLegislativaPesquisaView |
|
|
from sapl.norma.models import NormaJuridica |
|
|
from sapl.norma.models import NormaJuridica |
|
|
from sapl.parlamentares.models import (Filiacao, Legislatura, Parlamentar, |
|
|
from sapl.parlamentares.models import (Filiacao, Legislatura, Parlamentar, |
|
|
SessaoLegislativa) |
|
|
SessaoLegislativa, Mandato) ### |
|
|
from sapl.sessao.apps import AppConfig |
|
|
from sapl.sessao.apps import AppConfig |
|
|
from sapl.sessao.forms import ExpedienteMateriaForm, OrdemDiaForm |
|
|
from sapl.sessao.forms import ExpedienteMateriaForm, OrdemDiaForm |
|
|
|
|
|
|
|
|
@ -533,7 +533,7 @@ class SessaoPermissionMixin(PermissionRequiredForAppCrudMixin, |
|
|
|
|
|
|
|
|
class PresencaMixin: |
|
|
class PresencaMixin: |
|
|
|
|
|
|
|
|
def get_presencas(self): |
|
|
def get_presencas_demais(self): |
|
|
self.object = self.get_object() |
|
|
self.object = self.get_object() |
|
|
|
|
|
|
|
|
presencas = SessaoPlenariaPresenca.objects.filter( |
|
|
presencas = SessaoPlenariaPresenca.objects.filter( |
|
|
@ -541,13 +541,39 @@ class PresencaMixin: |
|
|
) |
|
|
) |
|
|
presentes = [p.parlamentar for p in presencas] |
|
|
presentes = [p.parlamentar for p in presencas] |
|
|
|
|
|
|
|
|
for parlamentar in Parlamentar.objects.filter(ativo=True): |
|
|
mandato = Mandato.objects.filter( |
|
|
|
|
|
legislatura_id=self.object.legislatura_id) |
|
|
|
|
|
|
|
|
|
|
|
mandato_parlamentar = [p.parlamentar for p in mandato] |
|
|
|
|
|
|
|
|
|
|
|
for parlamentar in mandato_parlamentar: |
|
|
|
|
|
if parlamentar in Parlamentar.objects.filter(ativo=False): |
|
|
|
|
|
if parlamentar in presentes: |
|
|
|
|
|
yield (parlamentar, True) |
|
|
|
|
|
else: |
|
|
|
|
|
yield (parlamentar, False) |
|
|
|
|
|
|
|
|
|
|
|
def get_presencas_ativos(self): |
|
|
|
|
|
self.object = self.get_object() |
|
|
|
|
|
|
|
|
|
|
|
presencas = SessaoPlenariaPresenca.objects.filter( |
|
|
|
|
|
sessao_plenaria_id=self.object.id |
|
|
|
|
|
) |
|
|
|
|
|
presentes = [p.parlamentar for p in presencas] |
|
|
|
|
|
|
|
|
|
|
|
mandato = Mandato.objects.filter( |
|
|
|
|
|
legislatura_id=self.object.legislatura_id) |
|
|
|
|
|
|
|
|
|
|
|
mandato_parlamentar = [p.parlamentar for p in mandato] |
|
|
|
|
|
|
|
|
|
|
|
for parlamentar in mandato_parlamentar: |
|
|
|
|
|
if parlamentar in Parlamentar.objects.filter(ativo=True): |
|
|
if parlamentar in presentes: |
|
|
if parlamentar in presentes: |
|
|
yield (parlamentar, True) |
|
|
yield (parlamentar, True) |
|
|
else: |
|
|
else: |
|
|
yield (parlamentar, False) |
|
|
yield (parlamentar, False) |
|
|
|
|
|
|
|
|
def get_presencas_ordem(self): |
|
|
def get_presencas_ordem_demais(self): |
|
|
self.object = self.get_object() |
|
|
self.object = self.get_object() |
|
|
|
|
|
|
|
|
presencas = PresencaOrdemDia.objects.filter( |
|
|
presencas = PresencaOrdemDia.objects.filter( |
|
|
@ -555,7 +581,33 @@ class PresencaMixin: |
|
|
) |
|
|
) |
|
|
presentes = [p.parlamentar for p in presencas] |
|
|
presentes = [p.parlamentar for p in presencas] |
|
|
|
|
|
|
|
|
for parlamentar in Parlamentar.objects.filter(ativo=True): |
|
|
mandato = Mandato.objects.filter( |
|
|
|
|
|
legislatura_id=self.object.legislatura_id) |
|
|
|
|
|
|
|
|
|
|
|
mandato_parlamentar = [p.parlamentar for p in mandato] |
|
|
|
|
|
|
|
|
|
|
|
for parlamentar in mandato_parlamentar: |
|
|
|
|
|
if parlamentar in Parlamentar.objects.filter(ativo=False): |
|
|
|
|
|
if parlamentar in presentes: |
|
|
|
|
|
yield (parlamentar, True) |
|
|
|
|
|
else: |
|
|
|
|
|
yield (parlamentar, False) |
|
|
|
|
|
|
|
|
|
|
|
def get_presencas_ordem_ativos(self): |
|
|
|
|
|
self.object = self.get_object() |
|
|
|
|
|
|
|
|
|
|
|
presencas = PresencaOrdemDia.objects.filter( |
|
|
|
|
|
sessao_plenaria_id=self.object.id |
|
|
|
|
|
) |
|
|
|
|
|
presentes = [p.parlamentar for p in presencas] |
|
|
|
|
|
|
|
|
|
|
|
mandato = Mandato.objects.filter( |
|
|
|
|
|
legislatura_id=self.object.legislatura_id) |
|
|
|
|
|
|
|
|
|
|
|
mandato_parlamentar = [p.parlamentar for p in mandato] |
|
|
|
|
|
|
|
|
|
|
|
for parlamentar in mandato_parlamentar: |
|
|
|
|
|
if parlamentar in Parlamentar.objects.filter(ativo=True): |
|
|
if parlamentar in presentes: |
|
|
if parlamentar in presentes: |
|
|
yield (parlamentar, True) |
|
|
yield (parlamentar, True) |
|
|
else: |
|
|
else: |
|
|
@ -585,13 +637,13 @@ class PresencaView(FormMixin, PresencaMixin, DetailView): |
|
|
sessao_plenaria_id=self.object.id) |
|
|
sessao_plenaria_id=self.object.id) |
|
|
|
|
|
|
|
|
# Id dos parlamentares presentes |
|
|
# Id dos parlamentares presentes |
|
|
marcados = request.POST.getlist('presenca') |
|
|
marcados = request.POST.getlist('presenca_ativos') + request.POST.getlist('presenca_demais') |
|
|
|
|
|
|
|
|
# Deletar os que foram desmarcadors |
|
|
# Deletar os que foram desmarcadors |
|
|
deletar = set(set(presentes_banco) - set(marcados)) |
|
|
deletar = set(set(presentes_banco) - set(marcados)) |
|
|
for d in deletar: |
|
|
for d in deletar: |
|
|
SessaoPlenariaPresenca.objects.filter( |
|
|
SessaoPlenariaPresenca.objects.filter( |
|
|
parlamentar_id=d.parlamentar_id).delete() |
|
|
parlamentar_id=d.parlamentar_id, sessao_plenaria_id=self.object.id).delete() |
|
|
|
|
|
|
|
|
for p in marcados: |
|
|
for p in marcados: |
|
|
sessao = SessaoPlenariaPresenca() |
|
|
sessao = SessaoPlenariaPresenca() |
|
|
@ -693,13 +745,13 @@ class PresencaOrdemDiaView(FormMixin, PresencaMixin, DetailView): |
|
|
sessao_plenaria_id=pk) |
|
|
sessao_plenaria_id=pk) |
|
|
|
|
|
|
|
|
# Id dos parlamentares presentes |
|
|
# Id dos parlamentares presentes |
|
|
marcados = request.POST.getlist('presenca') |
|
|
marcados = request.POST.getlist('presenca_ativos') + request.POST.getlist('presenca_demais') |
|
|
|
|
|
|
|
|
# Deletar os que foram desmarcadors |
|
|
# Deletar os que foram desmarcadors |
|
|
deletar = set(set(presentes_banco) - set(marcados)) |
|
|
deletar = set(set(presentes_banco) - set(marcados)) |
|
|
for d in deletar: |
|
|
for d in deletar: |
|
|
PresencaOrdemDia.objects.filter( |
|
|
PresencaOrdemDia.objects.filter( |
|
|
parlamentar_id=d.parlamentar_id).delete() |
|
|
parlamentar_id=d.parlamentar_id, sessao_plenaria_id=self.object.id).delete() |
|
|
|
|
|
|
|
|
for p in marcados: |
|
|
for p in marcados: |
|
|
ordem = PresencaOrdemDia() |
|
|
ordem = PresencaOrdemDia() |
|
|
|