Repository: interlegis/sapl

Issue:
Telas de parlamentar para usuário anônimo
- Parlamentar:
  Mandatos | Comissões | Relatorias | Proposições | Filiações Partidárias | Ínicio
  **Tirar Dependetes**
  **Listagem de parlamentar para usuário anônimo aparece a foto do parlamentar**



Discussion:

Resolving patch:
diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py
--- a/sapl/parlamentares/urls.py
+++ b/sapl/parlamentares/urls.py
@@ -5,7 +5,10 @@
                                       FiliacaoCrud, LegislaturaCrud,
                                       MandatoCrud, MesaDiretoraView,
                                       NivelInstrucaoCrud, ParlamentarCrud,
-                                      PartidoCrud, SessaoLegislativaCrud,
+                                      ParticipacaoParlamentarCrud, PartidoCrud,
+                                      ProposicaoParlamentarCrud,
+                                      RelatoriaParlamentarCrud,
+                                      SessaoLegislativaCrud,
                                       TipoAfastamentoCrud, TipoDependenteCrud,
                                       TipoMilitarCrud)
 
@@ -16,7 +19,10 @@
 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() +
+        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
--- a/sapl/parlamentares/views.py
+++ b/sapl/parlamentares/views.py
@@ -2,16 +2,19 @@
 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.exceptions import ObjectDoesNotExist
+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 _
 from django.views.generic import FormView
 
+from sapl.comissoes.models import Participacao
 from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
                             CrudDeleteView, CrudDetailView, CrudListView,
                             CrudUpdateView)
 from sapl.crud.masterdetail import MasterDetailCrud
+from sapl.materia.models import Proposicao, Relatoria
 from sapl.utils import permissao_tb_aux, permissoes_parlamentares
 
 from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm,
@@ -22,6 +25,93 @@
                      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'
+    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'
+    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, 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 ' +
+                         p.composicao.periodo.data_fim.strftime("%d/%m/%Y"),
+                         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'


Test patch: