Browse Source

Faz o merge com o Master

pull/282/head
Eduardo Calil 9 years ago
parent
commit
3aefd498cb
  1. 24
      materia/forms.py
  2. 4
      materia/test_materia_urls.py
  3. 31
      materia/views.py
  4. 6
      parlamentares/test_parlamentares_urls.py
  5. 2
      templates/materia/materialegislativa_filter.html
  6. 8
      templates/materia/pesquisa_materia.html
  7. 26
      templates/materia/pesquisa_materia_list.html

24
materia/forms.py

@ -1,17 +1,18 @@
import crispy_layout_mixin
import django_filters import django_filters
import sapl
from crispy_forms.helper import FormHelper 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 import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models import Max from django.db.models import Max
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 _
from django.utils.text import capfirst
from django_filters import FilterSet 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 norma.models import LegislacaoCitada, TipoNormaJuridica
from parlamentares.models import Parlamentar, Partido from parlamentares.models import Parlamentar, Partido
from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.settings import MAX_DOC_UPLOAD_SIZE
@ -603,7 +604,7 @@ class RangeWidgetOverride(forms.MultiWidget):
return ''.join(rendered_widgets) return ''.join(rendered_widgets)
class MateriaLegislativaPesquisaFields(FilterSet): class MateriaLegislativaFilterSet(FilterSet):
numero = django_filters.CharFilter(required=False, numero = django_filters.CharFilter(required=False,
label=u'Número da Matéria', label=u'Número da Matéria',
@ -707,13 +708,6 @@ class MateriaLegislativaPesquisaFields(FilterSet):
('tipoD', 'Tipo, Ano, Numero, Data - Ordem Decrescente') ('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): def get_order_by(self, order_value):
if order_value == '': if order_value == '':
return [] return []
@ -725,11 +719,11 @@ class MateriaLegislativaPesquisaFields(FilterSet):
return ['tipo__sigla', 'ano', 'numero', 'data_apresentacao'] return ['tipo__sigla', 'ano', 'numero', 'data_apresentacao']
else: else:
return ['-tipo__sigla', '-ano', '-numero', '-data_apresentacao'] return ['-tipo__sigla', '-ano', '-numero', '-data_apresentacao']
return super(MateriaLegislativaPesquisaFields, return super(MateriaLegislativaFilterSet,
self).get_order_by(order_value) self).get_order_by(order_value)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MateriaLegislativaPesquisaFields, self).__init__(*args, **kwargs) super(MateriaLegislativaFilterSet, self).__init__(*args, **kwargs)
row1 = crispy_layout_mixin.to_row( row1 = crispy_layout_mixin.to_row(
[('tipo', 12)]) [('tipo', 12)])

4
materia/test_materia_urls.py

@ -1,12 +1,8 @@
import pytest import pytest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
import pytest
@pytest.mark.parametrize("test_input,kwargs,expected", [ @pytest.mark.parametrize("test_input,kwargs,expected", [
('materia:pesquisar_materia_list',
{},
'/materia/pesquisar-materia-list'),
('materia:relatoria_edit', ('materia:relatoria_edit',
{'pk': '11', 'id': '99'}, {'pk': '11', 'id': '99'},
'/materia/11/relatoria/99/edit'), '/materia/11/relatoria/99/edit'),

31
materia/views.py

@ -1,14 +1,16 @@
from django_filters.views import FilterView import os
from datetime import datetime 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.contrib import messages
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import send_mail from django.core.mail import send_mail
from django.core.urlresolvers import reverse, reverse_lazy from django.core.urlresolvers import reverse, reverse_lazy
from django.db.models import Max
from django.http.response import HttpResponseRedirect from django.http.response import HttpResponseRedirect
from django.shortcuts import redirect from django.shortcuts import redirect
from django.template import Context, loader 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.views.generic import CreateView, FormView, ListView, TemplateView
from django_filters.views import FilterView 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 norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica
from parlamentares.models import Partido from parlamentares.models import Partido
from random import choice
from sapl.utils import get_base_url from sapl.utils import get_base_url
from string import ascii_letters, digits
from .forms import (AcompanhamentoMateriaForm, AutoriaForm, from .forms import (AcompanhamentoMateriaForm, AutoriaForm,
DespachoInicialForm, DocumentoAcessorioForm, DespachoInicialForm, DocumentoAcessorioForm,
FormularioCadastroForm, FormularioSimplificadoForm, FormularioCadastroForm, FormularioSimplificadoForm,
filtra_tramitacao_status, filtra_tramitacao_destino,
filtra_tramitacao_destino_and_status,
LegislacaoCitadaForm, MateriaAnexadaForm, LegislacaoCitadaForm, MateriaAnexadaForm,
MateriaLegislativaPesquisaFields, NumeracaoForm, MateriaLegislativaFilterSet, NumeracaoForm,
ProposicaoForm, RelatoriaForm, TramitacaoForm) ProposicaoForm, RelatoriaForm, TramitacaoForm,
filtra_tramitacao_destino,
filtra_tramitacao_destino_and_status,
filtra_tramitacao_status)
from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
DespachoInicial, DocumentoAcessorio, MateriaLegislativa, DespachoInicial, DocumentoAcessorio, MateriaLegislativa,
Numeracao, Orgao, Origem, Proposicao, RegimeTramitacao, Numeracao, Orgao, Origem, Proposicao, RegimeTramitacao,
@ -39,6 +41,7 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)
OrigemCrud = Crud.build(Origem, 'origem') OrigemCrud = Crud.build(Origem, 'origem')
TipoMateriaCrud = Crud.build(TipoMateriaLegislativa, TipoMateriaCrud = Crud.build(TipoMateriaLegislativa,
'tipo_materia_legislativa') 'tipo_materia_legislativa')
@ -1198,7 +1201,7 @@ class ProposicaoListView(ListView):
class MateriaLegislativaPesquisaView(FilterView): class MateriaLegislativaPesquisaView(FilterView):
model = MateriaLegislativa model = MateriaLegislativa
filterset_class = MateriaLegislativaPesquisaFields filterset_class = MateriaLegislativaFilterSet
paginate_by = 10 paginate_by = 10
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
@ -1221,7 +1224,7 @@ class MateriaLegislativaPesquisaView(FilterView):
status_tramitacao = data.get('tramitacao__status') status_tramitacao = data.get('tramitacao__status')
unidade_destino = data.get('tramitacao__unidade_tramitacao_destino') unidade_destino = data.get('tramitacao__unidade_tramitacao_destino')
# import ipdb; ipdb.set_trace()
if status_tramitacao and unidade_destino: if status_tramitacao and unidade_destino:
lista = filtra_tramitacao_destino_and_status(status_tramitacao, lista = filtra_tramitacao_destino_and_status(status_tramitacao,
unidade_destino) unidade_destino)

6
parlamentares/test_parlamentares_urls.py

@ -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'

2
templates/materia/materialegislativa_filter.html

@ -25,7 +25,7 @@
<tr> <tr>
<td> <td>
<strong><a href="{% url 'materialegislativa:detail' m.id %}">{{m.tipo.sigla}} {{m.numero}}/{{m.ano}} - {{m.tipo}}</strong></a></br> <strong><a href="{% url 'materia:materialegislativa_detail' m.id %}">{{m.tipo.sigla}} {{m.numero}}/{{m.ano}} - {{m.tipo}}</strong></a></br>
{{ m.ementa|safe }}</br> {{ m.ementa|safe }}</br>
<strong>Localização Atual:</strong> {{m.tramitacao_set.last.unidade_tramitacao_destino|default_if_none:"Não Informada"}}</br> <strong>Localização Atual:</strong> {{m.tramitacao_set.last.unidade_tramitacao_destino|default_if_none:"Não Informada"}}</br>
<p></p> <p></p>

8
templates/materia/pesquisa_materia.html

@ -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 %}

26
templates/materia/pesquisa_materia_list.html

@ -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 %}
<table class="table table-striped table-bordered">
<thead class="thead-default">
<tr><td><h3>Resultados</h3></td></tr>
</thead>
{% for m in materias %}
<tr>
<td>
<strong><a href="{% url 'materia:materialegislativa_detail' m.id %}">{{m.tipo.sigla}} {{m.numero}}/{{m.ano}} - {{m.tipo}}</strong></a></br>
{{ m.ementa|safe }}</br>
<strong>Localização Atual:</strong> {{m.tramitacao_set.last.unidade_tramitacao_destino|default_if_none:"Não Informada"}}</br>
<p></p>
</tr>
{% endfor %}
</table>
{% include "paginacao.html" %}
{% else %}
<h2>Nenhum Registro recuperado</h2>
{% endif %}
{% endblock detail_content %}
Loading…
Cancel
Save