diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 4f78b593b..0d1a14071 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -1,4 +1,5 @@ from django import forms +from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from django.views.generic import ListView from django.views.generic.edit import FormMixin @@ -108,6 +109,16 @@ class ProtocoloPesquisaView(ListView, FormMixin): template_name = 'protocoloadm/protocolo_pesquisa.html' form_class = ProtocoloForm + extra_context = {} + + def get_success_url(self): + return reverse('protocolo') + + def get_context_data(self, **kwargs): + context = super(ProtocoloPesquisaView, self).get_context_data(**kwargs) + context.update(self.extra_context) + return context + def get_queryset(self): return Protocolo.objects.all() @@ -155,8 +166,7 @@ class ProtocoloPesquisaView(ListView, FormMixin): protocolos = Protocolo.objects.filter( **kwargs) - # context = self.get_context_data() - # context.update({'pesquisa_set': protocolos}) + self.extra_context['protocolos'] = protocolos return self.form_valid(form) else: diff --git a/templates/protocoloadm/protocolo_pesquisa.html b/templates/protocoloadm/protocolo_pesquisa.html index 2e5115aa0..f4a04128d 100644 --- a/templates/protocoloadm/protocolo_pesquisa.html +++ b/templates/protocoloadm/protocolo_pesquisa.html @@ -67,6 +67,15 @@
+ + {% if protocolos %} + + {% for p in protocolos %} + + {% endfor %} +
{{ p.numero }}{{ p.assunto_ementa }}
+ Total: {{ protocolos|length }} + {% endif %} {% endblock detail_content %}