@ -18,11 +18,12 @@ from sapl.comissoes.forms import (ComissaoForm, ComposicaoForm,
DocumentoAcessorioCreateForm ,
DocumentoAcessorioCreateForm ,
DocumentoAcessorioEditForm ,
DocumentoAcessorioEditForm ,
ParticipacaoCreateForm , ParticipacaoEditForm ,
ParticipacaoCreateForm , ParticipacaoEditForm ,
PeriodoForm , Reunia oForm , Pauta ReuniaoForm)
PautaReuniaoForm , Period oForm , ReuniaoForm )
from sapl . crud . base import ( RP_DETAIL , RP_LIST , Crud , CrudAux ,
from sapl . crud . base import ( RP_DETAIL , RP_LIST , Crud , CrudAux ,
MasterDetailCrud ,
MasterDetailCrud ,
PermissionRequiredForAppCrudMixin )
PermissionRequiredForAppCrudMixin )
from sapl . materia . models import MateriaLegislativa , Tramitacao , PautaReuniao
from sapl . materia . models import ( MateriaLegislativa , Tramitacao , PautaReuniao ,
MateriaEmTramitacao )
from . models import ( CargoComissao , Comissao , Composicao , DocumentoAcessorio ,
from . models import ( CargoComissao , Comissao , Composicao , DocumentoAcessorio ,
Participacao , Periodo , Reuniao , TipoComissao )
Participacao , Periodo , Reuniao , TipoComissao )
@ -165,17 +166,12 @@ class ComissaoCrud(Crud):
return super ( Crud . UpdateView , self ) . form_valid ( form )
return super ( Crud . UpdateView , self ) . form_valid ( form )
# Essa função retorna objetos MateriaEmTramitacao
def lista_materias_comissao ( comissao_pk ) :
def lista_materias_comissao ( comissao_pk ) :
ts = Tramitacao . objects . order_by (
materias = MateriaEmTramitacao . objects . filter (
' materia_id ' , ' -data_tramitacao ' , ' -id ' ) . annotate (
tramitacao__unidade_tramitacao_destino__comissao = comissao_pk
comissao = F ( ' unidade_tramitacao_destino__comissao ' ) ) . distinct (
) . order_by ( ' materia__tipo ' , ' -materia__ano ' , ' -materia__numero ' )
' materia ' ) . values_list ( ' materia ' , ' comissao ' )
ts = [ m for ( m , c ) in ts if c == int ( comissao_pk ) ]
materias = MateriaLegislativa . objects . filter (
pk__in = ts ) . order_by ( ' tipo ' , ' -ano ' , ' -numero ' )
return materias
return materias
@ -184,13 +180,13 @@ class MateriasTramitacaoListView(ListView):
paginate_by = 10
paginate_by = 10
def get_queryset ( self ) :
def get_queryset ( self ) :
return lista_materias_comissao ( self . kwargs [ ' pk ' ] )
return list ( lista_materias_comissao ( self . kwargs [ ' pk ' ] ) )
def get_context_data ( self , * * kwargs ) :
def get_context_data ( self , * * kwargs ) :
context = super (
context = super (
MateriasTramitacaoListView , self ) . get_context_data ( * * kwargs )
MateriasTramitacaoListView , self ) . get_context_data ( * * kwargs )
context [ ' object ' ] = Comissao . objects . get ( id = self . kwargs [ ' pk ' ] )
context [ ' object ' ] = Comissao . objects . get ( id = self . kwargs [ ' pk ' ] )
context [ ' qtde ' ] = self . object_list . count ( )
context [ ' qtde ' ] = len ( self . object_list )
return context
return context