Browse Source

Fix #683 e #690

pull/701/head
LeandroRoberto 8 years ago
parent
commit
80783c1ed5
  1. 25
      sapl/sessao/views.py
  2. 3
      sapl/templates/crud/detail.html
  3. 4
      sapl/templates/sessao/sessaoplenaria_filter.html

25
sapl/sessao/views.py

@ -12,6 +12,7 @@ from django.utils.decorators import method_decorator
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView, TemplateView from django.views.generic import ListView, TemplateView
from django.views.generic.base import RedirectView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from django_filters.views import FilterView from django_filters.views import FilterView
@ -45,6 +46,7 @@ from .models import (Bancada, Bloco, CargoBancada, CargoMesa,
SessaoPlenariaPresenca, TipoExpediente, SessaoPlenariaPresenca, TipoExpediente,
TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar) TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar)
# OrdemDiaCrud = Crud.build(OrdemDia, '') # OrdemDiaCrud = Crud.build(OrdemDia, '')
# RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') # RegistroVotacaoCrud = Crud.build(RegistroVotacao, '')
TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria') TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
@ -427,8 +429,27 @@ class SessaoCrud(Crud):
list_field_names = ['data_inicio', 'legislatura', 'sessao_legislativa', list_field_names = ['data_inicio', 'legislatura', 'sessao_legislativa',
'tipo'] 'tipo']
class ListView(Crud.ListView): @property
ordering = ['-data_inicio'] def list_url(self):
return ''
@property
def cancel_url(self):
return self.search_url
@property
def search_url(self):
namespace = self.model._meta.app_config.name
return reverse('%s:%s' % (namespace, 'pesquisar_sessao'))
class ListView(Crud.ListView, RedirectView):
def get_redirect_url(self, *args, **kwargs):
namespace = self.model._meta.app_config.name
return reverse('%s:%s' % (namespace, 'pesquisar_sessao'))
def get(self, request, *args, **kwargs):
return RedirectView.get(self, request, *args, **kwargs)
class CreateView(Crud.CreateView): class CreateView(Crud.CreateView):

3
sapl/templates/crud/detail.html

@ -9,6 +9,9 @@
{% if view.list_url %} {% if view.list_url %}
<a href="{{ view.list_url }}" class="btn btn-default">{% trans 'Listar' %} {{view.verbose_name_plural}}</a> <a href="{{ view.list_url }}" class="btn btn-default">{% trans 'Listar' %} {{view.verbose_name_plural}}</a>
{% endif %} {% endif %}
{% if view.search_url %}
<a href="{{ view.search_url }}" class="btn btn-default">{% trans 'Fazer Nova Pesquisa' %}</a>
{% endif %}
{% if view.create_url %} {% if view.create_url %}
<a href="{{ view.create_url }}" class="btn btn-default"> <a href="{{ view.create_url }}" class="btn btn-default">
{% blocktrans with verbose_name=view.verbose_name %} Adicionar {{ verbose_name }} {% endblocktrans %} {% blocktrans with verbose_name=view.verbose_name %} Adicionar {{ verbose_name }} {% endblocktrans %}

4
sapl/templates/sessao/sessaoplenaria_filter.html

@ -6,7 +6,7 @@
<div class="actions btn-group pull-right" role="group"> <div class="actions btn-group pull-right" role="group">
{% if perms.sessao %} {% if perms.sessao %}
<a href="{% url 'sapl.sessao:sessaoplenaria_create' %}" class="btn btn-default"> <a href="{% url 'sapl.sessao:sessaoplenaria_create' %}" class="btn btn-default">
{% blocktrans with verbose_name=view.verbose_name %} Adicionar Sessão Plenária {% endblocktrans %} {% blocktrans with verbose_name=view.verbose_name %} Adicionar Sessão Plenária {% endblocktrans %}
{% endif %} {% endif %}
</a> </a>
{% if filter_url %} {% if filter_url %}
@ -50,4 +50,4 @@
{% endif %} {% endif %}
{% endblock detail_content %} {% endblock detail_content %}
{% block table_content %} {% block table_content %}
{% endblock table_content %} {% endblock table_content %}

Loading…
Cancel
Save