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] =?UTF-8?q?Cria=20tela=20de=20comiss=C3=B5es=20dentro=20de?= =?UTF-8?q?=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