diff --git a/protocoloadm/urls.py b/protocoloadm/urls.py index d054a5acc..cb95c1f45 100644 --- a/protocoloadm/urls.py +++ b/protocoloadm/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import include, url -from protocoloadm.views import (anular_protocolo_crud, +from protocoloadm.views import (ProtocoloPesquisaView, anular_protocolo_crud, documento_acessorio_administrativo_crud, documento_administrativo_crud, protocolo_documento_crud, @@ -23,5 +23,6 @@ urlpatterns = [ url(r'^protocoloadm/protocolo-mat/', include(protocolo_materia_crud.urls)), url(r'^protocoloadm/anular-protocolo/', include(anular_protocolo_crud.urls)), - + url(r'^protocoloadm/protocolo', + ProtocoloPesquisaView.as_view(), name='protocolo'), ] diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 690593b5d..4f78b593b 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -1,5 +1,8 @@ +from django import forms from django.utils.translation import ugettext_lazy as _ - +from django.views.generic import ListView +from django.views.generic.edit import FormMixin +from materia.models import TipoMateriaLegislativa from sapl.crud import build_crud from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo, @@ -85,3 +88,76 @@ anular_protocolo_crud = build_crud( [('numero', 6), ('ano', 6)], [('justificativa_anulacao', 12)]], ]) + + +class ProtocoloForm(forms.Form): + tipo_protocolo = forms.CharField(required=False) + numero_protocolo = forms.CharField(required=False) + ano = forms.CharField(required=False) + inicial = forms.DateField(required=False) + final = forms.DateField(required=False) + natureza_processo = forms.CharField(required=False) + tipo_documento = forms.CharField(required=False) + interessado = forms.CharField(required=False) + tipo_materia = forms.CharField(required=False) + autor = forms.CharField(required=False) + assunto = forms.CharField(required=False) + + +class ProtocoloPesquisaView(ListView, FormMixin): + template_name = 'protocoloadm/protocolo_pesquisa.html' + form_class = ProtocoloForm + + def get_queryset(self): + return Protocolo.objects.all() + + def get_tipo_documento(self): + return TipoDocumentoAdministrativo.objects.all() + + def get_tipo_materia(self): + return TipoMateriaLegislativa.objects.all() + + def post(self, request, *args, **kwargs): + form = self.get_form() + if form.is_valid(): + kwargs = {} + + if request.POST['tipo_protocolo']: + kwargs['tipo_protocolo'] = request.POST['tipo_protocolo'] + + if request.POST['numero_protocolo']: + kwargs['numero'] = request.POST['numero_protocolo'] + + if request.POST['ano']: + kwargs['ano'] = request.POST['ano'] + + if request.POST['inicial']: + kwargs['inicial'] = request.POST['inicial'] + + if request.POST['final']: + kwargs['final'] = request.POST['final'] + + if request.POST['tipo_documento']: + kwargs['tipo_documento'] = request.POST['tipo_documento'] + + if request.POST['interessado']: + kwargs['interessado'] = request.POST['interessado'] + + if request.POST['tipo_materia']: + kwargs['tipo_materia'] = request.POST['tipo_materia'] + + if request.POST['autor']: + kwargs['autor'] = request.POST['autor'] + + if request.POST['assunto']: + kwargs['assunto'] = request.POST['assunto'] + + protocolos = Protocolo.objects.filter( + **kwargs) + + # context = self.get_context_data() + # context.update({'pesquisa_set': protocolos}) + + return self.form_valid(form) + else: + return self.form_invalid(form) diff --git a/templates/protocoloadm/protocolo_pesquisa.html b/templates/protocoloadm/protocolo_pesquisa.html new file mode 100644 index 000000000..2e5115aa0 --- /dev/null +++ b/templates/protocoloadm/protocolo_pesquisa.html @@ -0,0 +1,85 @@ +{% extends "protocoloadm/protocoloadm_detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block detail_content %} +
+{% endblock detail_content %} + +{% block foot_js %} + +{% endblock %} \ No newline at end of file diff --git a/templates/protocoloadm/protocolo_resultados.html b/templates/protocoloadm/protocolo_resultados.html new file mode 100644 index 000000000..bdef04c78 --- /dev/null +++ b/templates/protocoloadm/protocolo_resultados.html @@ -0,0 +1,6 @@ +{% extends "protocoloadm/protocoloadm_detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block detail_content %} +{% endblock detail_content %} diff --git a/templates/protocoloadm/protocoloadm_detail.html b/templates/protocoloadm/protocoloadm_detail.html new file mode 100644 index 000000000..aaaeeaf22 --- /dev/null +++ b/templates/protocoloadm/protocoloadm_detail.html @@ -0,0 +1,10 @@ +{% extends "crud/detail.html" %} +{% load i18n %} + +{% block sections_nav %} +