@@ -646,9 +646,16 @@ def __init__(self, *args, **kwargs):
646646class OradorForm (ModelForm ):
647647 def __init__ (self , * args , ** kwargs ):
648648 super ().__init__ (* args , ** kwargs )
649+
650+ sessao = SessaoPlenaria .objects .get (id = self .initial ['id_sessao' ])
649651 self .fields ['parlamentar' ].queryset = \
650652 Parlamentar .objects .filter (
651- mandato__legislatura__sessaoplenaria = self .initial ['id_sessao' ], ativo = True ).order_by ('nome_parlamentar' )
653+ mandato__data_inicio_mandato__isnull = False ,
654+ mandato__data_fim_mandato__isnull = False ,
655+ mandato__data_inicio_mandato__lte = sessao .data_inicio ,
656+ mandato__data_fim_mandato__gte = sessao .data_inicio ,
657+ ativo = True
658+ ).distinct ().order_by ('nome_parlamentar' )
652659
653660 def clean (self ):
654661 super (OradorForm , self ).clean ()
@@ -687,7 +694,12 @@ def __init__(self, *args, **kwargs):
687694 super ().__init__ (* args , ** kwargs )
688695 self .fields ['parlamentar' ].queryset = \
689696 Parlamentar .objects .filter (
690- mandato__legislatura__sessaoplenaria = self .initial ['id_sessao' ], ativo = True ).order_by ('nome_parlamentar' )
697+ mandato__data_inicio_mandato__isnull = False ,
698+ mandato__data_fim_mandato__isnull = False ,
699+ mandato__data_inicio_mandato__lte = sessao .data_inicio ,
700+ mandato__data_fim_mandato__gte = sessao .data_inicio ,
701+ ativo = True
702+ ).distinct ().order_by ('nome_parlamentar' )
691703
692704 def clean (self ):
693705 super (OradorExpedienteForm , self ).clean ()
0 commit comments