diff --git a/comissoes/urls.py b/comissoes/urls.py index 36df60295..75f1d4835 100644 --- a/comissoes/urls.py +++ b/comissoes/urls.py @@ -5,11 +5,13 @@ from comissoes.views import (CadastrarComissaoView, ComissaoParlamentarIncluirView, ComposicaoView, MateriasView, ReunioesView, cargo_crud, comissao_crud, periodo_composicao_crud, - tipo_comissao_crud) + tipo_comissao_crud, MateriasTramitacaoListView) comissao_url_patterns = comissao_crud.urlpatterns + [ url(r'^(?P\d+)/composicao$', ComposicaoView.as_view(), name='composicao'), + url(r'^(?P\d+)/materias-em-tramitacao$', + MateriasTramitacaoListView.as_view(), name='materias_em_tramitacao'), url(r'^(?P\d+)/composicao/(?P\d+)/parlamentar$', ComissaoParlamentarIncluirView.as_view(), name='comissao_parlamentar'), diff --git a/comissoes/views.py b/comissoes/views.py index da66555c5..a5c9789c5 100644 --- a/comissoes/views.py +++ b/comissoes/views.py @@ -6,6 +6,7 @@ from django.contrib import messages from django.core.urlresolvers import reverse from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ +from django.views.generic import ListView from django.views.generic.edit import FormMixin from parlamentares.models import Filiacao from sapl.crud import build_crud @@ -13,6 +14,7 @@ from vanilla import GenericView from .models import (CargoComissao, Comissao, Composicao, Participacao, Periodo, TipoComissao) +from materia.models import Tramitacao cargo_crud = build_crud( CargoComissao, 'cargo_comissao', [ @@ -373,3 +375,20 @@ class ComissaoParlamentarEditView(FormMixin, GenericView): return self.render_to_response({'form': form, 'comissao': comissao, 'composicao_id': self.kwargs['id']}) + + +class MateriasTramitacaoListView(ListView): + template_name = "comissoes/materias_em_tramitacao.html" + paginate_by = 10 + + def get_queryset(self): + pk = self.kwargs['pk'] + tramitacoes = Tramitacao.objects.filter( + unidade_tramitacao_local__comissao=pk) + return tramitacoes + + def get_context_data(self, **kwargs): + context = super( + MateriasTramitacaoListView, self).get_context_data(**kwargs) + context['comissao'] = Comissao.objects.get(id=self.kwargs['pk']) + return context diff --git a/templates/comissoes/comissao_detail.html b/templates/comissoes/comissao_detail.html index ed96c52ce..e301b7223 100644 --- a/templates/comissoes/comissao_detail.html +++ b/templates/comissoes/comissao_detail.html @@ -4,5 +4,6 @@ {% endblock sections_nav %} diff --git a/templates/comissoes/composicao.html b/templates/comissoes/composicao.html index 336edbbe0..708a2363b 100644 --- a/templates/comissoes/composicao.html +++ b/templates/comissoes/composicao.html @@ -2,7 +2,6 @@ {% load i18n %} {% load crispy_forms_tags %} {% block actions %} {% endblock %} -

Composição

{% block detail_content %} {% if composicao_id != 0 %} diff --git a/templates/comissoes/materias_em_tramitacao.html b/templates/comissoes/materias_em_tramitacao.html new file mode 100644 index 000000000..b76aae7d2 --- /dev/null +++ b/templates/comissoes/materias_em_tramitacao.html @@ -0,0 +1,24 @@ +{% extends "comissoes/comissao_detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} +{% block actions %} {% endblock %} + +{% block detail_content %} +
+ {{comissao}} + + Há {{page_obj|length}} matéria(s) em tramitação nesta unidade.

+ + {% for tramitacao in page_obj %} + + {{tramitacao.materia.tipo.sigla}} {{tramitacao.materia.numero}} {{tramitacao.materia.ano}} - {{tramitacao.materia.tipo}} +
+ {{tramitacao.materia}}
+ Autor: {{tramitacao.materia.autoria_set.first.autor.nome}}
+ Situação: {{tramitacao.status.descricao}}
+
+ {% endfor %} + +
+ +{% endblock detail_content %} \ No newline at end of file