From 6d6397d841f13359ec17b8a7c2d72c49965a0641 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 8 Oct 2015 08:21:53 -0300 Subject: [PATCH] Add Pesquisa results in ProtocoloPesquisaView --- protocoloadm/views.py | 14 ++++++++++++-- templates/protocoloadm/protocolo_pesquisa.html | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) 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 %}