Browse Source

Add jquery-ui and refactor pesquisa protocolo

pull/7/head
Edward Ribeiro 9 years ago
parent
commit
416681fc99
  1. 1
      protocoloadm/urls.py
  2. 53
      protocoloadm/views.py
  3. 1
      sapl/settings.py
  4. 19
      templates/protocoloadm/protocolo_pesquisa.html

1
protocoloadm/urls.py

@ -1,5 +1,4 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from protocoloadm.views import (ProtocoloPesquisaView, anular_protocolo_crud, from protocoloadm.views import (ProtocoloPesquisaView, anular_protocolo_crud,
documento_acessorio_administrativo_crud, documento_acessorio_administrativo_crud,
documento_administrativo_crud, documento_administrativo_crud,

53
protocoloadm/views.py

@ -4,6 +4,7 @@ from django import forms
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView from django.views.generic import ListView
from django.views.generic.edit import UpdateView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from materia.models import TipoMateriaLegislativa from materia.models import TipoMateriaLegislativa
@ -95,28 +96,35 @@ anular_protocolo_crud = build_crud(
class ProtocoloForm(forms.Form): class ProtocoloForm(forms.Form):
tipo_protocolo = forms.CharField(required=False) tipo_protocolo = forms.CharField(label='Tipo de Protocolo', required=False)
numero_protocolo = forms.CharField(required=False) numero_protocolo = forms.CharField(label='Número de Protocolo', required=False)
ano = forms.CharField(required=False) ano = forms.CharField(label='Ano', required=False)
inicial = forms.DateField(required=False) inicial = forms.DateField(label='Data Inicial', required=False)
final = forms.DateField(required=False) final = forms.DateField(label='Data Final', required=False)
natureza_processo = forms.CharField(required=False) natureza_processo = forms.CharField(label='Natureza Processo', required=False)
tipo_documento = forms.CharField(required=False) tipo_documento = forms.CharField(label='Tipo de Documento', required=False)
interessado = forms.CharField(required=False) interessado = forms.CharField(label='Interessado', required=False)
tipo_materia = forms.CharField(required=False) tipo_materia = forms.CharField(label='Tipo de Matéria', required=False)
autor = forms.CharField(required=False) autor = forms.CharField(label='Autor', required=False)
assunto = forms.CharField(required=False) assunto = forms.CharField(label='Assunto <DFS', required=False)
class ProtocoloPesquisaView(ListView, FormMixin): class ProtocoloPesquisaView(FormMixin, ListView):
template_name = 'protocoloadm/protocolo_pesquisa.html' template_name = 'protocoloadm/protocolo_pesquisa.html'
form_class = ProtocoloForm form_class = ProtocoloForm
context_object_name = 'protocolos'
paginate_by = 10
extra_context = {} extra_context = {}
def get_success_url(self): def get_success_url(self):
return reverse('protocolo') return reverse('protocolo')
def get_form(self, data=None, files=None, **kwargs):
# kwargs['user'] = self.request.user
# return AccountForm(data, files, **kwargs)
return ProtocoloForm()
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ProtocoloPesquisaView, self).get_context_data(**kwargs) context = super(ProtocoloPesquisaView, self).get_context_data(**kwargs)
context.update(self.extra_context) context.update(self.extra_context)
@ -131,8 +139,20 @@ class ProtocoloPesquisaView(ListView, FormMixin):
def get_tipo_materia(self): def get_tipo_materia(self):
return TipoMateriaLegislativa.objects.all() return TipoMateriaLegislativa.objects.all()
# def get(self, request, *args, **kwargs):
# context = self.get_context_data(self)
# form = ProtocoloForm()
# # return self.render(request, self.template_name, {'form': form})
# context.update({'form': form})
# return self.render_to_response(context)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.get_form() #form = self.get_form()
form = ProtocoloForm(request.POST or None)
if form.is_valid(): if form.is_valid():
kwargs = {} kwargs = {}
@ -173,7 +193,8 @@ class ProtocoloPesquisaView(ListView, FormMixin):
**kwargs) **kwargs)
self.extra_context['protocolos'] = protocolos self.extra_context['protocolos'] = protocolos
self.extra_context['form'] = form
return self.form_valid(form) return self.form_valid(form)
else: else:
return self.form_invalid(form) return self.form_invalid(form)

1
sapl/settings.py

@ -149,6 +149,7 @@ BOWER_INSTALLED_APPS = (
'components-font-awesome', 'components-font-awesome',
'foundation-icon-fonts', 'foundation-icon-fonts',
'tinymce', 'tinymce',
'jquery-ui',
'jquery-runner', 'jquery-runner',
) )

19
templates/protocoloadm/protocolo_pesquisa.html

@ -78,13 +78,30 @@
</tr> </tr>
{% for p in protocolos %} {% for p in protocolos %}
<tr><td>{{ p.numero }}</td> <tr><td>{{ p.numero }}</td>
<td>{{ p.ano }}</td>
<td>{{ p.assunto_ementa }}</td> <td>{{ p.assunto_ementa }}</td>
<td>{{ p.tipo_documento }}</td> <td>{{ p.tipo_documento }}</td>
<td>{{ p.ano }}</td>
<td>{{ p.data|date:"d/m/Y" }}</td> <td>{{ p.data|date:"d/m/Y" }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
<!-- {% if is_paginated %}
<div class="pagination">
<span class="page-links">
{% if page_obj.has_previous %}
<a href="{% url 'protocolo' %}{?page={{ page_obj.previous_page_number }}"><<</a>
{% endif %}
<span class="page-current">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
</span>
{% if page_obj.has_next %}
<a href="{% url 'protocolo' %}/?page={{ page_obj.next_page_number }}">>></a>
{% endif %}
</span>
</div>
{% endif %} -->
Total: {{ protocolos|length }} Total: {{ protocolos|length }}
{% endif %} {% endif %}
</form> </form>

Loading…
Cancel
Save