diff --git a/materia/forms.py b/materia/forms.py index 2b00df5b8..300b84a3a 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -1,17 +1,18 @@ +import crispy_layout_mixin import django_filters +import sapl + from crispy_forms.helper import FormHelper -from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Submit +from crispy_forms.layout import Button, Column, Fieldset, HTML, Layout, Submit +from crispy_layout_mixin import form_actions + from django import forms from django.core.exceptions import ValidationError from django.db.models import Max from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ -from django.utils.text import capfirst from django_filters import FilterSet -import crispy_layout_mixin -import sapl -from crispy_layout_mixin import form_actions from norma.models import LegislacaoCitada, TipoNormaJuridica from parlamentares.models import Parlamentar, Partido from sapl.settings import MAX_DOC_UPLOAD_SIZE @@ -603,7 +604,7 @@ class RangeWidgetOverride(forms.MultiWidget): return ''.join(rendered_widgets) -class MateriaLegislativaPesquisaFields(FilterSet): +class MateriaLegislativaFilterSet(FilterSet): numero = django_filters.CharFilter(required=False, label=u'Número da Matéria', @@ -707,13 +708,6 @@ class MateriaLegislativaPesquisaFields(FilterSet): ('tipoD', 'Tipo, Ano, Numero, Data - Ordem Decrescente') ) - # def get_ordering_field(self, choices): - # super( - # MateriaLegislativaPesquisaFields, self).get_ordering_field(choices) - # return forms.ChoiceField(label=_('Ordenação'), - # required=False, - # choices=choices) - def get_order_by(self, order_value): if order_value == '': return [] @@ -725,11 +719,11 @@ class MateriaLegislativaPesquisaFields(FilterSet): return ['tipo__sigla', 'ano', 'numero', 'data_apresentacao'] else: return ['-tipo__sigla', '-ano', '-numero', '-data_apresentacao'] - return super(MateriaLegislativaPesquisaFields, + return super(MateriaLegislativaFilterSet, self).get_order_by(order_value) def __init__(self, *args, **kwargs): - super(MateriaLegislativaPesquisaFields, self).__init__(*args, **kwargs) + super(MateriaLegislativaFilterSet, self).__init__(*args, **kwargs) row1 = crispy_layout_mixin.to_row( [('tipo', 12)]) diff --git a/materia/test_materia_urls.py b/materia/test_materia_urls.py index 0ff4aba0e..492adde94 100644 --- a/materia/test_materia_urls.py +++ b/materia/test_materia_urls.py @@ -1,12 +1,8 @@ import pytest from django.core.urlresolvers import reverse -import pytest @pytest.mark.parametrize("test_input,kwargs,expected", [ - ('materia:pesquisar_materia_list', - {}, - '/materia/pesquisar-materia-list'), ('materia:relatoria_edit', {'pk': '11', 'id': '99'}, '/materia/11/relatoria/99/edit'), diff --git a/materia/views.py b/materia/views.py index c4fd9f9a4..fabbd0864 100644 --- a/materia/views.py +++ b/materia/views.py @@ -1,14 +1,16 @@ -from django_filters.views import FilterView +import os from datetime import datetime -from random import choice -from string import ascii_letters, digits + +from base.models import CasaLegislativa +from comissoes.models import Comissao, Composicao +from compilacao.views import IntegracaoTaView +from crud.base import Crud, make_pagination from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist from django.core.mail import send_mail from django.core.urlresolvers import reverse, reverse_lazy -from django.db.models import Max from django.http.response import HttpResponseRedirect from django.shortcuts import redirect from django.template import Context, loader @@ -16,22 +18,22 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import CreateView, FormView, ListView, TemplateView from django_filters.views import FilterView -from base.models import CasaLegislativa -from comissoes.models import Comissao, Composicao -from compilacao.views import IntegracaoTaView -from crud.base import Crud, make_pagination from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica from parlamentares.models import Partido +from random import choice from sapl.utils import get_base_url +from string import ascii_letters, digits + from .forms import (AcompanhamentoMateriaForm, AutoriaForm, DespachoInicialForm, DocumentoAcessorioForm, FormularioCadastroForm, FormularioSimplificadoForm, - filtra_tramitacao_status, filtra_tramitacao_destino, - filtra_tramitacao_destino_and_status, LegislacaoCitadaForm, MateriaAnexadaForm, - MateriaLegislativaPesquisaFields, NumeracaoForm, - ProposicaoForm, RelatoriaForm, TramitacaoForm) + MateriaLegislativaFilterSet, NumeracaoForm, + ProposicaoForm, RelatoriaForm, TramitacaoForm, + filtra_tramitacao_destino, + filtra_tramitacao_destino_and_status, + filtra_tramitacao_status) from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, DespachoInicial, DocumentoAcessorio, MateriaLegislativa, Numeracao, Orgao, Origem, Proposicao, RegimeTramitacao, @@ -39,6 +41,7 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, Tramitacao, UnidadeTramitacao) + OrigemCrud = Crud.build(Origem, 'origem') TipoMateriaCrud = Crud.build(TipoMateriaLegislativa, 'tipo_materia_legislativa') @@ -1198,7 +1201,7 @@ class ProposicaoListView(ListView): class MateriaLegislativaPesquisaView(FilterView): model = MateriaLegislativa - filterset_class = MateriaLegislativaPesquisaFields + filterset_class = MateriaLegislativaFilterSet paginate_by = 10 def get_context_data(self, **kwargs): @@ -1221,7 +1224,7 @@ class MateriaLegislativaPesquisaView(FilterView): status_tramitacao = data.get('tramitacao__status') unidade_destino = data.get('tramitacao__unidade_tramitacao_destino') - # import ipdb; ipdb.set_trace() + if status_tramitacao and unidade_destino: lista = filtra_tramitacao_destino_and_status(status_tramitacao, unidade_destino) diff --git a/parlamentares/test_parlamentares_urls.py b/parlamentares/test_parlamentares_urls.py deleted file mode 100644 index c72c8c0be..000000000 --- a/parlamentares/test_parlamentares_urls.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.core.urlresolvers import reverse - - -def test_urls_materia(): - st = reverse('materia:pesquisar_materia_list') - assert st == '/materia/pesquisar-materia-list' diff --git a/templates/materia/materialegislativa_filter.html b/templates/materia/materialegislativa_filter.html index 787009651..9ede56069 100644 --- a/templates/materia/materialegislativa_filter.html +++ b/templates/materia/materialegislativa_filter.html @@ -25,7 +25,7 @@ - {{m.tipo.sigla}} {{m.numero}}/{{m.ano}} - {{m.tipo}}
+ {{m.tipo.sigla}} {{m.numero}}/{{m.ano}} - {{m.tipo}}
{{ m.ementa|safe }}
Localização Atual: {{m.tramitacao_set.last.unidade_tramitacao_destino|default_if_none:"Não Informada"}}

diff --git a/templates/materia/pesquisa_materia.html b/templates/materia/pesquisa_materia.html deleted file mode 100644 index 56f5cfa55..000000000 --- a/templates/materia/pesquisa_materia.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "materia/materialegislativa_detail.html" %} -{% load i18n %} -{% load crispy_forms_tags %} -{% block actions %}{% endblock %} -{% block sections_nav %}{% endblock %} -{% block detail_content %} - {% crispy form %} -{% endblock %} diff --git a/templates/materia/pesquisa_materia_list.html b/templates/materia/pesquisa_materia_list.html deleted file mode 100644 index 83a17712a..000000000 --- a/templates/materia/pesquisa_materia_list.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "materia/materialegislativa_detail.html" %} -{% load i18n %} -{% load crispy_forms_tags %} -{% block actions %}{% endblock %} -{% block sections_nav %} {% endblock %} -{% block detail_content %} -{% if materias %} - - - - - {% for m in materias %} - - - {% endfor %} -

Resultados

- {{m.tipo.sigla}} {{m.numero}}/{{m.ano}} - {{m.tipo}}
- {{ m.ementa|safe }}
- Localização Atual: {{m.tramitacao_set.last.unidade_tramitacao_destino|default_if_none:"Não Informada"}}
-

-
-{% include "paginacao.html" %} -{% else %} -

Nenhum Registro recuperado

-{% endif %} -{% endblock detail_content %}