Browse Source

Merge pull request #548 from interlegis/526-parlamentar-usuario-anonimo

Fix #526 telas de parlamentar para usuario anonimo
pull/579/head
Edward 8 years ago
committed by GitHub
parent
commit
08e9c85d2b
  1. 10
      sapl/parlamentares/urls.py
  2. 92
      sapl/parlamentares/views.py
  3. 6
      sapl/templates/parlamentares/subnav.yaml

10
sapl/parlamentares/urls.py

@ -5,7 +5,10 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud,
FiliacaoCrud, LegislaturaCrud, FiliacaoCrud, LegislaturaCrud,
MandatoCrud, MesaDiretoraView, MandatoCrud, MesaDiretoraView,
NivelInstrucaoCrud, ParlamentarCrud, NivelInstrucaoCrud, ParlamentarCrud,
PartidoCrud, SessaoLegislativaCrud, ParticipacaoParlamentarCrud, PartidoCrud,
ProposicaoParlamentarCrud,
RelatoriaParlamentarCrud,
SessaoLegislativaCrud,
TipoAfastamentoCrud, TipoDependenteCrud, TipoAfastamentoCrud, TipoDependenteCrud,
TipoMilitarCrud) TipoMilitarCrud)
@ -16,7 +19,10 @@ app_name = AppConfig.name
urlpatterns = [ urlpatterns = [
url(r'^parlamentar/', include( url(r'^parlamentar/', include(
ParlamentarCrud.get_urls() + DependenteCrud.get_urls() + 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/', url(r'^coligacao/',
include(ColigacaoCrud.get_urls() + include(ColigacaoCrud.get_urls() +

92
sapl/parlamentares/views.py

@ -2,16 +2,19 @@ from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType 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.shortcuts import redirect
from django.utils.datastructures import MultiValueDictKeyError from django.utils.datastructures import MultiValueDictKeyError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import FormView from django.views.generic import FormView
from sapl.comissoes.models import Participacao
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDeleteView, CrudDetailView, CrudListView, CrudDeleteView, CrudDetailView, CrudListView,
CrudUpdateView) CrudUpdateView)
from sapl.crud.masterdetail import MasterDetailCrud from sapl.crud.masterdetail import MasterDetailCrud
from sapl.materia.models import Proposicao, Relatoria
from sapl.utils import permissao_tb_aux, permissoes_parlamentares from sapl.utils import permissao_tb_aux, permissoes_parlamentares
from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm,
@ -22,6 +25,93 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
SituacaoMilitar, TipoAfastamento, TipoDependente) 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): class CargoMesaCrud(Crud):
model = CargoMesa model = CargoMesa
help_path = 'cargo_mesa' help_path = 'cargo_mesa'

6
sapl/templates/parlamentares/subnav.yaml

@ -7,3 +7,9 @@
url: filiacao_list url: filiacao_list
- title: {% trans 'Dependentes' %} - title: {% trans 'Dependentes' %}
url: dependente_list url: dependente_list
- title: {% trans 'Comissões' %}
url: participacao_list
- title: {% trans 'Proposições' %}
url: proposicao_list
- title: {% trans 'Relatorias' %}
url: relatoria_list

Loading…
Cancel
Save