Browse Source

Adiciona tele de proposições dentro de parlamentar

pull/548/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
af0df59007
  1. 4
      sapl/parlamentares/urls.py
  2. 33
      sapl/parlamentares/views.py
  3. 2
      sapl/templates/parlamentares/subnav.yaml

4
sapl/parlamentares/urls.py

@ -6,6 +6,7 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud,
MandatoCrud, MesaDiretoraView, MandatoCrud, MesaDiretoraView,
NivelInstrucaoCrud, ParlamentarCrud, NivelInstrucaoCrud, ParlamentarCrud,
ParticipacaoParlamentarCrud, PartidoCrud, ParticipacaoParlamentarCrud, PartidoCrud,
ProposicaoParlamentarCrud,
SessaoLegislativaCrud, SessaoLegislativaCrud,
TipoAfastamentoCrud, TipoDependenteCrud, TipoAfastamentoCrud, TipoDependenteCrud,
TipoMilitarCrud) TipoMilitarCrud)
@ -18,7 +19,8 @@ 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() ParticipacaoParlamentarCrud.get_urls() +
ProposicaoParlamentarCrud.get_urls()
)), )),
url(r'^coligacao/', url(r'^coligacao/',
include(ColigacaoCrud.get_urls() + include(ColigacaoCrud.get_urls() +

33
sapl/parlamentares/views.py

@ -2,6 +2,7 @@ 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.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse, reverse_lazy 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
@ -13,6 +14,7 @@ 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
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,
@ -23,6 +25,37 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
SituacaoMilitar, TipoAfastamento, TipoDependente) 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): class ParticipacaoParlamentarCrud(MasterDetailCrud):
model = Participacao model = Participacao
parent_field = 'parlamentar' parent_field = 'parlamentar'

2
sapl/templates/parlamentares/subnav.yaml

@ -9,3 +9,5 @@
url: dependente_list url: dependente_list
- title: {% trans 'Comissões' %} - title: {% trans 'Comissões' %}
url: participacao_list url: participacao_list
- title: {% trans 'Proposições' %}
url: proposicao_list

Loading…
Cancel
Save