Browse Source

Init Pesquisa Protocolo

pull/7/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
7a3a98546c
  1. 5
      protocoloadm/urls.py
  2. 78
      protocoloadm/views.py
  3. 85
      templates/protocoloadm/protocolo_pesquisa.html
  4. 6
      templates/protocoloadm/protocolo_resultados.html
  5. 10
      templates/protocoloadm/protocoloadm_detail.html

5
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'),
]

78
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)

85
templates/protocoloadm/protocolo_pesquisa.html

@ -0,0 +1,85 @@
{% extends "protocoloadm/protocoloadm_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<form method="post">
{% csrf_token %}
<fieldset>
<legend>Pesquisa Avançada</legend>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li>Tipo Protocolo</li>
<li>
<select name="tipo_protocolo">
<option value="">Selecione</option>
<option value="0">Enviado</option>
<option value="1">Recebido</option>
</select>
</li>
</ul>
<ul class="small-block-grid-4 medium-block-grid-4 large-block-grid-4">
<li>Número Protocolo</li>
<li><input type="text" name="numero_protocolo" /></li>
<li>Ano</li>
<li><input type="text" name="ano" /></li>
</ul>
<ul class="small-block-grid-5 medium-block-grid-5 large-block-grid-5">
<li>Período Protocolo</li>
<li>Inicial</li>
<li><input type="text" name="inicial" class="dateinput" /></li>
<li>Final</li>
<li><input type="text" name="final" class="dateinput" /></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li>Tipo Documento</li>
<li>
<select name="tipo_documento">
<option value="">Selecione</option>
{% for tipo in view.get_tipo_documento %}
<option value="{{tipo.id}}">{{tipo.sigla}} - {{tipo.descricao}}</option>
{% endfor %}
</select>
</li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li>Interessado</li>
<li><input type="text" name="interessado" /></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li>Tipo Matéria</li>
<li>
<select name="tipo_materia">
<option value="">Selecione</option>
{% for tipo in view.get_tipo_materia %}
<option value="{{tipo.id}}">{{tipo.sigla}} - {{tipo.descricao}}</option>
{% endfor %}
</select>
</li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li>Autor</li>
<li><input type="text" name="autor" /></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li>Assunto</li>
<li><input type="text" name="assunto" /></li>
</ul>
<br />
<input type="submit" value="Pesquisar" class="button primary"/>
</fieldset>
</form>
{% endblock detail_content %}
{% block foot_js %}
<script type="text/javascript">
$(function () {
$('.dateinput').fdatepicker({
// TODO localize
format: 'dd/mm/yyyy',
language: 'pt',
endDate: '31/12/2100',
todayBtn: true
});
});
</script>
{% endblock %}

6
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 %}

10
templates/protocoloadm/protocoloadm_detail.html

@ -0,0 +1,10 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block sections_nav %}
<dl class="sub-nav left">
<dd><a href="" class="button secondary">{% trans 'Protocolar Documento' %}</a></dd>
<dd><a href="" class="button secondary">{% trans 'Protocolar Matéria' %}</a></dd>
<dd><a href="" class="button secondary">{% trans 'Anular Protocolo' %}</a></dd>
</dl>
{% endblock sections_nav %}
Loading…
Cancel
Save