From 8813fc1fc6a558319b343dd569c37b6d755c921a Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 9 Sep 2016 13:33:38 -0300 Subject: [PATCH] =?UTF-8?q?Torna=20os=20campo=20de=20periodo=20obrigat?= =?UTF-8?q?=C3=B3rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 1 + sapl/base/views.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) 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 ''