diff --git a/sapl/base/forms.py b/sapl/base/forms.py index fc37bbc3d..2e6a65bef 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -56,6 +56,7 @@ class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet): *args, **kwargs) self.filters['data_inicio'].label = 'Período (Inicial - Final)' + self.form.fields['data_inicio'].required = True row1 = to_row([('data_inicio', 12)]) diff --git a/sapl/base/views.py b/sapl/base/views.py index c5b41219f..2f26e67c8 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -46,6 +46,11 @@ class RelatorioPresencaSessaoView(FilterView): context = super(RelatorioPresencaSessaoView, self).get_context_data(**kwargs) context['title'] = _('Presença dos parlamentares nas sessões') + + # Verifica se os campos foram preenchidos + if not self.filterset.form.is_valid(): + return context + # ===================================================================== if 'salvar' in self.request.GET: where = context['object_list'].query.where @@ -71,15 +76,17 @@ class RelatorioPresencaSessaoView(FilterView): 'sessao_plenaria').filter(**param0).distinct( 'sessao_plenaria').count() - self.calcular_porcentagem_presenca(pls, - context['object_list'].count(), - total_ordemdia) + self.calcular_porcentagem_presenca( + pls, + context['object_list'].count(), + total_ordemdia) context['total_ordemdia'] = total_ordemdia context['total_sessao'] = context['object_list'].count() context['parlamentares'] = pls - context['periodo'] = (self.request.GET['data_inicio_0'] + - ' - ' + self.request.GET['data_inicio_1']) + context['periodo'] = ( + self.request.GET['data_inicio_0'] + + ' - ' + self.request.GET['data_inicio_1']) # ===================================================================== qr = self.request.GET.copy() context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''