Browse Source

Cria método separado para listagem de frentes no parlamentar

pull/587/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
5c114c33d1
  1. 13
      sapl/parlamentares/urls.py
  2. 21
      sapl/parlamentares/views.py
  3. 21
      sapl/templates/parlamentares/frentes.html
  4. 2
      sapl/templates/parlamentares/subnav.yaml

13
sapl/parlamentares/urls.py

@ -2,10 +2,10 @@ from django.conf.urls import include, url
from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud,
ComposicaoColigacaoCrud, DependenteCrud, ComposicaoColigacaoCrud, DependenteCrud,
FiliacaoCrud, FrenteCrud, FiliacaoCrud, FrenteCrud, FrenteList,
FrenteParlamentarCrud, LegislaturaCrud, LegislaturaCrud, MandatoCrud,
MandatoCrud, MesaDiretoraView, MesaDiretoraView, NivelInstrucaoCrud,
NivelInstrucaoCrud, ParlamentarCrud, ParlamentarCrud,
ParticipacaoParlamentarCrud, PartidoCrud, ParticipacaoParlamentarCrud, PartidoCrud,
ProposicaoParlamentarCrud, ProposicaoParlamentarCrud,
RelatoriaParlamentarCrud, RelatoriaParlamentarCrud,
@ -23,9 +23,12 @@ urlpatterns = [
FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + FiliacaoCrud.get_urls() + MandatoCrud.get_urls() +
ParticipacaoParlamentarCrud.get_urls() + ParticipacaoParlamentarCrud.get_urls() +
ProposicaoParlamentarCrud.get_urls() + ProposicaoParlamentarCrud.get_urls() +
RelatoriaParlamentarCrud.get_urls() + FrenteParlamentarCrud.get_urls() RelatoriaParlamentarCrud.get_urls()
)), )),
url(r'^parlamentar/(?P<pk>\d+)/frente$',
FrenteList.as_view(), name="frent_list"),
url(r'^sistema/coligacao/', url(r'^sistema/coligacao/',
include(ColigacaoCrud.get_urls() + include(ColigacaoCrud.get_urls() +
ComposicaoColigacaoCrud.get_urls())), ComposicaoColigacaoCrud.get_urls())),

21
sapl/parlamentares/views.py

@ -7,7 +7,7 @@ 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, ListView
from sapl.comissoes.models import Participacao from sapl.comissoes.models import Participacao
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
@ -25,10 +25,17 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
SituacaoMilitar, TipoAfastamento, TipoDependente) SituacaoMilitar, TipoAfastamento, TipoDependente)
class FrenteParlamentarCrud(MasterDetailCrud): class FrenteList(ListView):
model = Frente model = Frente
parent_field = 'parlamentares' paginate_by = 10
help_path = '' template_name = 'parlamentares/frentes.html'
def get_queryset(self):
return Frente.objects.filter(parlamentares__in=[self.kwargs['pk']])
def get_context_data(self, **kwargs):
return {'root_pk': self.kwargs['pk'],
'object_list': self.get_queryset()}
class FrenteCrud(Crud): class FrenteCrud(Crud):
@ -36,15 +43,15 @@ class FrenteCrud(Crud):
help_path = '' help_path = ''
class BaseMixin(CrudBaseMixin): class BaseMixin(CrudBaseMixin):
permission_required = permissoes_parlamentares()
list_field_names = ['nome', 'data_criacao', 'parlamentares'] list_field_names = ['nome', 'data_criacao', 'parlamentares']
def has_permission(self):
return permissao_tb_aux(self)
class CreateView(PermissionRequiredMixin, CrudCreateView): class CreateView(PermissionRequiredMixin, CrudCreateView):
permission_required = permissoes_parlamentares()
form_class = FrenteForm form_class = FrenteForm
class UpdateView(PermissionRequiredMixin, CrudUpdateView): class UpdateView(PermissionRequiredMixin, CrudUpdateView):
permission_required = permissoes_parlamentares()
form_class = FrenteForm form_class = FrenteForm

21
sapl/templates/parlamentares/frentes.html

@ -0,0 +1,21 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
{% if object_list|length == 0 %}
<p>Nenhuma frente encontrada.</p>
{% else %}
<table class="table table-striped table-hover">
<thead>
<tr><th>Frentes</th></tr>
</thead>
<tbody>
{% for frente in object_list %}
<tr><td><a href="{% url 'sapl.parlamentares:frente_detail' frente.pk %}">{{ frente.nome }}</a></td></tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% include "paginacao.html" %}
{% endblock %}

2
sapl/templates/parlamentares/subnav.yaml

@ -14,4 +14,4 @@
- title: {% trans 'Relatorias' %} - title: {% trans 'Relatorias' %}
url: relatoria_list url: relatoria_list
- title: {% trans 'Frentes' %} - title: {% trans 'Frentes' %}
url: frente_list url:

Loading…
Cancel
Save