@@ -646,9 +646,16 @@ def __init__(self, *args, **kwargs):
646
646
class OradorForm (ModelForm ):
647
647
def __init__ (self , * args , ** kwargs ):
648
648
super ().__init__ (* args , ** kwargs )
649
+
650
+ sessao = SessaoPlenaria .objects .get (id = self .initial ['id_sessao' ])
649
651
self .fields ['parlamentar' ].queryset = \
650
652
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' )
652
659
653
660
def clean (self ):
654
661
super (OradorForm , self ).clean ()
@@ -687,7 +694,12 @@ def __init__(self, *args, **kwargs):
687
694
super ().__init__ (* args , ** kwargs )
688
695
self .fields ['parlamentar' ].queryset = \
689
696
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' )
691
703
692
704
def clean (self ):
693
705
super (OradorExpedienteForm , self ).clean ()
0 commit comments