|
@ -2,6 +2,7 @@ from crispy_forms.helper import FormHelper |
|
|
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Submit |
|
|
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Submit |
|
|
from django import forms |
|
|
from django import forms |
|
|
from django.core.exceptions import ValidationError |
|
|
from django.core.exceptions import ValidationError |
|
|
|
|
|
from django.db.models import Max |
|
|
from django_filters import FilterSet |
|
|
from django_filters import FilterSet |
|
|
from django.forms import ModelForm |
|
|
from django.forms import ModelForm |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
@ -19,7 +20,7 @@ from parlamentares.models import Parlamentar, Partido |
|
|
from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, |
|
|
from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, |
|
|
DespachoInicial, DocumentoAcessorio, MateriaLegislativa, |
|
|
DespachoInicial, DocumentoAcessorio, MateriaLegislativa, |
|
|
Numeracao, Origem, Proposicao, Relatoria, |
|
|
Numeracao, Origem, Proposicao, Relatoria, |
|
|
StatusTramitacao, TipoAutor, TipoDocumento, |
|
|
StatusTramitacao, TipoAutor, |
|
|
TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao) |
|
|
TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao) |
|
|
|
|
|
|
|
|
ORDENACAO_MATERIAIS = [(1, 'Crescente'), |
|
|
ORDENACAO_MATERIAIS = [(1, 'Crescente'), |
|
@ -799,11 +800,10 @@ class MateriaLegislativaPesquisaFields(FilterSet): |
|
|
'autoria__partido', |
|
|
'autoria__partido', |
|
|
'local_origem_externa'] |
|
|
'local_origem_externa'] |
|
|
|
|
|
|
|
|
def my_custom_filter(queryset, value): |
|
|
# def filter_tramitacao__status(status): |
|
|
materia = MateriaLegislativa.objects.raw( |
|
|
# ultimas_tramitacoes = Tramitacao.objects.values( |
|
|
'SELECT DISTINCT materia_id, \ |
|
|
# 'materia_id').annotate(data_encaminhamento=Max( |
|
|
max(data_encaminhamento) as data_encaminhamento \ |
|
|
# 'data_encaminhamento'), |
|
|
FROM materia_tramitacao \ |
|
|
# id=Max('id')) |
|
|
GROUP BY materia_id \ |
|
|
# ultimas_tramitacoes = ultimas_tramitacoes.filter(status=status) |
|
|
ORDER BY materia_id') |
|
|
# return ultimas_tramitacoes.materia |
|
|
return queryset.all() |
|
|
|
|
|