Browse Source

Fix pagination in protocolo list

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
cc9b5cb1c6
  1. 17
      protocoloadm/views.py

17
protocoloadm/views.py

@ -1,6 +1,7 @@
from datetime import date, datetime from datetime import date, datetime
from re import sub from re import sub
import sapl
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Field, Fieldset, Layout, Submit from crispy_forms.layout import ButtonHolder, Field, Fieldset, Layout, Submit
from django import forms from django import forms
@ -9,17 +10,16 @@ from django.core.urlresolvers import reverse
from django.db.models import Max from django.db.models import Max
from django.forms import ModelForm from django.forms import ModelForm
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import redirect, render from django.shortcuts import redirect
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from vanilla import GenericView
from materia.models import Proposicao, TipoMateriaLegislativa from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud from sapl.crud import build_crud
from vanilla import GenericView
from .models import (Autor, DocumentoAcessorioAdministrativo, from .models import (Autor, DocumentoAcessorioAdministrativo,
DocumentoAdministrativo, Protocolo, DocumentoAdministrativo, Protocolo,
@ -199,6 +199,17 @@ class ProtocoloListView(FormMixin, ListView):
return Protocolo.objects.filter( return Protocolo.objects.filter(
**kwargs) **kwargs)
def get_context_data(self, **kwargs):
context = super(ProtocoloListView, self).get_context_data(
**kwargs)
paginator = context['paginator']
page_obj = context['page_obj']
context['page_range'] = sapl.crud.make_pagination(
page_obj.number, paginator.num_pages)
return context
class ProtocoloPesquisaView(FormMixin, GenericView): class ProtocoloPesquisaView(FormMixin, GenericView):
template_name = 'protocoloadm/protocolo_pesquisa.html' template_name = 'protocoloadm/protocolo_pesquisa.html'

Loading…
Cancel
Save