Browse Source

relatorio por vigencia em andamento

pull/2429/head
Cesar Carvalho 7 years ago
parent
commit
c28281fdff
  1. 39
      sapl/base/forms.py
  2. 2
      sapl/base/views.py

39
sapl/base/forms.py

@ -733,52 +733,43 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True, ano = django_filters.ChoiceFilter(required=True,
label='Ano da Norma', label='Ano da Norma',
choices=RANGE_ANOS) choices=RANGE_ANOS,
method='filter_vigencia')
vigencia = forms.ChoiceField( vigencia = forms.ChoiceField(
label=_('Vigente'), label=_('Vigência'),
choices=[(True, "Vigente"), (False, "Não vigente")], choices=[(True, "Vigente"), (False, "Não vigente")],
widget=forms.RadioSelect(), widget=forms.RadioSelect(),
required=True, required=True)
help_text=_('Se vc está trocando ou removendo o usuário deste Autor, '
'como o Sistema deve proceder com o usuário que está sendo'
' desvinculado?'))
# filter_overrides = {models.DateField: {
# 'filter_class': django_filters.DateFromToRangeFilter,
# 'extra': lambda f: {
# 'label': '%s (%s)' % (f.verbose_name, _('Ano')),
# 'widget': RangeWidgetOverride}
# }}
@property
def qs(self):
parent = super(RelatorioNormasVigenciaFilterSet, self).qs
return parent.distinct().order_by('data')
class Meta:
model = NormaJuridica
# fields = ['ano', 'vigencia']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(RelatorioNormasVigenciaFilterSet, self).__init__( super(RelatorioNormasVigenciaFilterSet, self).__init__(
*args, **kwargs) *args, **kwargs)
self.filters['ano'].label = 'Ano' self.filters['ano'].label = 'Ano'
# self.filters['vigencia'].label = 'Vigência'
self.form.fields['ano'].required = True self.form.fields['ano'].required = True
# self.form.fields['vigencia'].required = True self.form.fields['vigencia'] = self.vigencia
row1 = to_row([('ano', 12)]) row1 = to_row([('ano', 12)])
# row2 = to_row([('vigencia', 12)]) row2 = to_row([('vigencia', 12)])
self.form.helper = FormHelper() self.form.helper = FormHelper()
self.form.helper.form_method = 'GET' self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout( self.form.helper.layout = Layout(
Fieldset(_('Normas por vigência.'), Fieldset(_('Normas por vigência.'),
row1, row1, row2,
form_actions(label='Pesquisar')) form_actions(label='Pesquisar'))
) )
@property
def qs(self):
return qs_override_django_filter(self)
def filter_vigencia(self, qs, *args, **kwargs):
import ipdb; ipdb.set_trace()
parent = super(RelatorioNormasVigenciaFilterSet, self).qs
return parent.distinct().order_by('data')
class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet): class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):

2
sapl/base/views.py

@ -790,6 +790,7 @@ class RelatorioNormasVigenciaView(FilterView):
self).get_context_data(**kwargs) self).get_context_data(**kwargs)
context['title'] = _('Normas por vigência') context['title'] = _('Normas por vigência')
# import ipdb; ipdb.set_trace()
# Verifica se os campos foram preenchidos # Verifica se os campos foram preenchidos
if not self.filterset.form.is_valid(): if not self.filterset.form.is_valid():
return context return context
@ -800,7 +801,6 @@ class RelatorioNormasVigenciaView(FilterView):
context['show_results'] = show_results_filter_set(qr) context['show_results'] = show_results_filter_set(qr)
context['ano'] = self.request.GET['ano'] context['ano'] = self.request.GET['ano']
# import ipdb; ipdb.set_trace()
return context return context

Loading…
Cancel
Save