|
@ -17,12 +17,10 @@ from django.forms import ModelForm, ModelChoiceField, widgets |
|
|
from django.forms.forms import Form |
|
|
from django.forms.forms import Form |
|
|
from django.forms.models import ModelMultipleChoiceField |
|
|
from django.forms.models import ModelMultipleChoiceField |
|
|
from django.forms.widgets import Select, CheckboxSelectMultiple, HiddenInput |
|
|
from django.forms.widgets import Select, CheckboxSelectMultiple, HiddenInput |
|
|
from django.utils import six |
|
|
|
|
|
from django.utils.encoding import force_text |
|
|
from django.utils.encoding import force_text |
|
|
from django.utils.html import format_html |
|
|
from django.utils.html import format_html |
|
|
from django.utils.safestring import mark_safe |
|
|
from django.utils.safestring import mark_safe |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django_filters.filterset import STRICTNESS |
|
|
|
|
|
import django_filters |
|
|
import django_filters |
|
|
|
|
|
|
|
|
from sapl.base.models import Autor, TipoAutor |
|
|
from sapl.base.models import Autor, TipoAutor |
|
@ -41,7 +39,8 @@ from sapl.settings import MAX_DOC_UPLOAD_SIZE |
|
|
from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, |
|
|
from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, |
|
|
ChoiceWithoutValidationField, |
|
|
ChoiceWithoutValidationField, |
|
|
MateriaPesquisaOrderingFilter, RangeWidgetOverride, |
|
|
MateriaPesquisaOrderingFilter, RangeWidgetOverride, |
|
|
autor_label, autor_modal, models_with_gr_for_model) |
|
|
autor_label, autor_modal, models_with_gr_for_model, |
|
|
|
|
|
qs_override_django_filter) |
|
|
import sapl |
|
|
import sapl |
|
|
|
|
|
|
|
|
from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, |
|
|
from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, |
|
@ -591,42 +590,7 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet): |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def qs(self): |
|
|
def qs(self): |
|
|
if not hasattr(self, '_qs'): |
|
|
return qs_override_django_filter(self) |
|
|
valid = self.is_bound and self.form.is_valid() |
|
|
|
|
|
|
|
|
|
|
|
if self.is_bound and not valid: |
|
|
|
|
|
if self.strict == STRICTNESS.RAISE_VALIDATION_ERROR: |
|
|
|
|
|
raise forms.ValidationError(self.form.errors) |
|
|
|
|
|
elif bool(self.strict) == STRICTNESS.RETURN_NO_RESULTS: |
|
|
|
|
|
self._qs = self.queryset.none() |
|
|
|
|
|
return self._qs |
|
|
|
|
|
# else STRICTNESS.IGNORE... ignoring |
|
|
|
|
|
|
|
|
|
|
|
# start with all the results and filter from there |
|
|
|
|
|
qs = self.queryset.all() |
|
|
|
|
|
for name, filter_ in six.iteritems(self.filters): |
|
|
|
|
|
value = None |
|
|
|
|
|
if valid: |
|
|
|
|
|
value = self.form.cleaned_data[name] |
|
|
|
|
|
else: |
|
|
|
|
|
raw_value = self.form[name].value() |
|
|
|
|
|
try: |
|
|
|
|
|
value = self.form.fields[name].clean(raw_value) |
|
|
|
|
|
except forms.ValidationError: |
|
|
|
|
|
if self.strict == STRICTNESS.RAISE_VALIDATION_ERROR: |
|
|
|
|
|
raise |
|
|
|
|
|
elif bool(self.strict) == STRICTNESS.RETURN_NO_RESULTS: |
|
|
|
|
|
self._qs = self.queryset.none() |
|
|
|
|
|
return self._qs |
|
|
|
|
|
# else STRICTNESS.IGNORE... ignoring |
|
|
|
|
|
|
|
|
|
|
|
if value is not None: # valid & clean data |
|
|
|
|
|
qs = qs._next_is_sticky() |
|
|
|
|
|
qs = filter_.filter(qs, value) |
|
|
|
|
|
|
|
|
|
|
|
self._qs = qs |
|
|
|
|
|
|
|
|
|
|
|
return self._qs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pega_ultima_tramitacao(): |
|
|
def pega_ultima_tramitacao(): |
|
|