From ef17a830ddc0049a79ea83a276d6555d5c2b973a Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 31 Aug 2016 11:38:40 -0300 Subject: [PATCH 1/5] =?UTF-8?q?Cria=20tela=20de=20comiss=C3=B5es=20dentro?= =?UTF-8?q?=20de=20parlamentar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/parlamentares/urls.py | 6 +++-- sapl/parlamentares/views.py | 34 ++++++++++++++++++++++++ sapl/templates/parlamentares/subnav.yaml | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 2235e5a12..496386551 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -5,7 +5,8 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, FiliacaoCrud, LegislaturaCrud, MandatoCrud, MesaDiretoraView, NivelInstrucaoCrud, ParlamentarCrud, - PartidoCrud, SessaoLegislativaCrud, + ParticipacaoParlamentarCrud, PartidoCrud, + SessaoLegislativaCrud, TipoAfastamentoCrud, TipoDependenteCrud, TipoMilitarCrud) @@ -16,7 +17,8 @@ app_name = AppConfig.name urlpatterns = [ url(r'^parlamentar/', include( ParlamentarCrud.get_urls() + DependenteCrud.get_urls() + - FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + + ParticipacaoParlamentarCrud.get_urls() )), url(r'^coligacao/', include(ColigacaoCrud.get_urls() + diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index e104cb91f..77136ff45 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -8,6 +8,7 @@ from django.utils.datastructures import MultiValueDictKeyError from django.utils.translation import ugettext_lazy as _ from django.views.generic import FormView +from sapl.comissoes.models import Participacao from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, CrudDeleteView, CrudDetailView, CrudListView, CrudUpdateView) @@ -22,6 +23,39 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, SituacaoMilitar, TipoAfastamento, TipoDependente) +class ParticipacaoParlamentarCrud(MasterDetailCrud): + model = Participacao + parent_field = 'parlamentar' + help_path = '' + + class ListView(MasterDetailCrud.ListView): + ordering = ('-composicao__periodo') + + def get_rows(self, object_list): + comissoes = [] + for p in object_list: + if p.cargo.nome != 'Relator': + comissao = [ + (p.composicao.comissao.nome, p.composicao.comissao.pk), + (p.cargo.nome, None), + (p.composicao.periodo, None) + ] + comissoes.append(comissao) + return comissoes + + def get_headers(self): + return ['Comissão', 'Cargo', 'Período'] + + class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView): + permission_required = permissoes_parlamentares() + + class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView): + permission_required = permissoes_parlamentares() + + class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + permission_required = permissoes_parlamentares() + + class CargoMesaCrud(Crud): model = CargoMesa help_path = 'cargo_mesa' diff --git a/sapl/templates/parlamentares/subnav.yaml b/sapl/templates/parlamentares/subnav.yaml index 9b457cd18..87068dcfa 100644 --- a/sapl/templates/parlamentares/subnav.yaml +++ b/sapl/templates/parlamentares/subnav.yaml @@ -7,3 +7,5 @@ url: filiacao_list - title: {% trans 'Dependentes' %} url: dependente_list +- title: {% trans 'Comissões' %} + url: participacao_list From de2d503eb8cf2a0d75832c1689d7450791098930 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 31 Aug 2016 11:47:45 -0300 Subject: [PATCH 2/5] Formata data do periodo --- sapl/parlamentares/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 77136ff45..6506c9739 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -38,7 +38,10 @@ class ParticipacaoParlamentarCrud(MasterDetailCrud): comissao = [ (p.composicao.comissao.nome, p.composicao.comissao.pk), (p.cargo.nome, None), - (p.composicao.periodo, None) + (p.composicao.periodo.data_inicio.strftime( + "%d/%m/%Y") + ' a ' + + p.composicao.periodo.data_fim.strftime("%d/%m/%Y"), + None) ] comissoes.append(comissao) return comissoes From 2ae39c763e9328043acc20725484d0635dedaba4 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 31 Aug 2016 12:06:03 -0300 Subject: [PATCH 3/5] Ajusta url de detalhe para comissao --- sapl/parlamentares/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 6506c9739..6bff705ec 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -2,7 +2,7 @@ from django.contrib import messages from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType -from django.core.urlresolvers import reverse_lazy +from django.core.urlresolvers import reverse, reverse_lazy from django.shortcuts import redirect from django.utils.datastructures import MultiValueDictKeyError from django.utils.translation import ugettext_lazy as _ @@ -36,7 +36,9 @@ class ParticipacaoParlamentarCrud(MasterDetailCrud): for p in object_list: if p.cargo.nome != 'Relator': comissao = [ - (p.composicao.comissao.nome, p.composicao.comissao.pk), + (p.composicao.comissao.nome, reverse( + 'sapl.comissoes:comissao_detail', kwargs={ + 'pk': p.composicao.comissao.pk})), (p.cargo.nome, None), (p.composicao.periodo.data_inicio.strftime( "%d/%m/%Y") + ' a ' + From af0df590072c583703670f90f49ecb62021ff032 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 31 Aug 2016 12:48:10 -0300 Subject: [PATCH 4/5] =?UTF-8?q?Adiciona=20tele=20de=20proposi=C3=A7=C3=B5e?= =?UTF-8?q?s=20dentro=20de=20parlamentar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/parlamentares/urls.py | 4 ++- sapl/parlamentares/views.py | 33 ++++++++++++++++++++++++ sapl/templates/parlamentares/subnav.yaml | 2 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 496386551..c08d2639e 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -6,6 +6,7 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, MandatoCrud, MesaDiretoraView, NivelInstrucaoCrud, ParlamentarCrud, ParticipacaoParlamentarCrud, PartidoCrud, + ProposicaoParlamentarCrud, SessaoLegislativaCrud, TipoAfastamentoCrud, TipoDependenteCrud, TipoMilitarCrud) @@ -18,7 +19,8 @@ urlpatterns = [ url(r'^parlamentar/', include( ParlamentarCrud.get_urls() + DependenteCrud.get_urls() + FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + - ParticipacaoParlamentarCrud.get_urls() + ParticipacaoParlamentarCrud.get_urls() + + ProposicaoParlamentarCrud.get_urls() )), url(r'^coligacao/', include(ColigacaoCrud.get_urls() + diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 6bff705ec..837059cd9 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -2,6 +2,7 @@ from django.contrib import messages from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType +from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse, reverse_lazy from django.shortcuts import redirect from django.utils.datastructures import MultiValueDictKeyError @@ -13,6 +14,7 @@ from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, CrudDeleteView, CrudDetailView, CrudListView, CrudUpdateView) from sapl.crud.masterdetail import MasterDetailCrud +from sapl.materia.models import Proposicao from sapl.utils import permissao_tb_aux, permissoes_parlamentares from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, @@ -23,6 +25,37 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, SituacaoMilitar, TipoAfastamento, TipoDependente) +class ProposicaoParlamentarCrud(MasterDetailCrud): + model = Proposicao + parent_field = 'autor__parlamentar' + help_path = '' + + class BaseMixin(CrudBaseMixin): + list_field_names = ['tipo', 'descricao'] + + class ListView(MasterDetailCrud.ListView): + permission_required = permissoes_parlamentares() + + def get_queryset(self): + try: + proposicoes = Proposicao.objects.filter( + autor__parlamentar_id=self.kwargs['pk'], + data_envio__isnull=False) + except ObjectDoesNotExist: + return [] + else: + return proposicoes + + class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView): + permission_required = permissoes_parlamentares() + + class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView): + permission_required = permissoes_parlamentares() + + class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + permission_required = permissoes_parlamentares() + + class ParticipacaoParlamentarCrud(MasterDetailCrud): model = Participacao parent_field = 'parlamentar' diff --git a/sapl/templates/parlamentares/subnav.yaml b/sapl/templates/parlamentares/subnav.yaml index 87068dcfa..a82cf68f8 100644 --- a/sapl/templates/parlamentares/subnav.yaml +++ b/sapl/templates/parlamentares/subnav.yaml @@ -9,3 +9,5 @@ url: dependente_list - title: {% trans 'Comissões' %} url: participacao_list +- title: {% trans 'Proposições' %} + url: proposicao_list From 9824a253275d4d4e81abddfba0625d219016f119 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 31 Aug 2016 13:00:10 -0300 Subject: [PATCH 5/5] Add tela relatorias em parlamentar --- sapl/parlamentares/urls.py | 4 +++- sapl/parlamentares/views.py | 20 +++++++++++++++++++- sapl/templates/parlamentares/subnav.yaml | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index c08d2639e..97f2a0347 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -7,6 +7,7 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, NivelInstrucaoCrud, ParlamentarCrud, ParticipacaoParlamentarCrud, PartidoCrud, ProposicaoParlamentarCrud, + RelatoriaParlamentarCrud, SessaoLegislativaCrud, TipoAfastamentoCrud, TipoDependenteCrud, TipoMilitarCrud) @@ -20,7 +21,8 @@ urlpatterns = [ ParlamentarCrud.get_urls() + DependenteCrud.get_urls() + FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + ParticipacaoParlamentarCrud.get_urls() + - ProposicaoParlamentarCrud.get_urls() + ProposicaoParlamentarCrud.get_urls() + + RelatoriaParlamentarCrud.get_urls() )), url(r'^coligacao/', include(ColigacaoCrud.get_urls() + diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 837059cd9..0f2a8edfb 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -14,7 +14,7 @@ from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, CrudDeleteView, CrudDetailView, CrudListView, CrudUpdateView) from sapl.crud.masterdetail import MasterDetailCrud -from sapl.materia.models import Proposicao +from sapl.materia.models import Proposicao, Relatoria from sapl.utils import permissao_tb_aux, permissoes_parlamentares from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, @@ -25,6 +25,24 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, SituacaoMilitar, TipoAfastamento, TipoDependente) +class RelatoriaParlamentarCrud(MasterDetailCrud): + model = Relatoria + parent_field = 'parlamentar' + help_path = '' + + class ListView(MasterDetailCrud.ListView): + permission_required = permissoes_parlamentares() + + class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView): + permission_required = permissoes_parlamentares() + + class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView): + permission_required = permissoes_parlamentares() + + class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + permission_required = permissoes_parlamentares() + + class ProposicaoParlamentarCrud(MasterDetailCrud): model = Proposicao parent_field = 'autor__parlamentar' diff --git a/sapl/templates/parlamentares/subnav.yaml b/sapl/templates/parlamentares/subnav.yaml index a82cf68f8..286e0fc9d 100644 --- a/sapl/templates/parlamentares/subnav.yaml +++ b/sapl/templates/parlamentares/subnav.yaml @@ -11,3 +11,5 @@ url: participacao_list - title: {% trans 'Proposições' %} url: proposicao_list +- title: {% trans 'Relatorias' %} + url: relatoria_list