Browse Source

Refactor Pesquisa Protocolo so that it passes qa_test

pull/11/merge
Edward Ribeiro 9 years ago
parent
commit
8ed354fe31
  1. 5
      protocoloadm/urls.py
  2. 31
      protocoloadm/views.py
  3. 2
      templates/protocoloadm/protocolo_pesquisa.html

5
protocoloadm/urls.py

@ -1,7 +1,7 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from protocoloadm.views import (AnularProtocoloAdmView, ProtocoloPesquisaView, from protocoloadm.views import (AnularProtocoloAdmView, ProtocoloListView,
ProtocoloListView, ProtocoloPesquisaView,
documento_acessorio_administrativo_crud, documento_acessorio_administrativo_crud,
documento_administrativo_crud, documento_administrativo_crud,
protocolo_documento_crud, protocolo_documento_crud,
@ -34,5 +34,4 @@ urlpatterns = [
# include(anular_protocolo_crud.urls), name='anular_protocolo'), # include(anular_protocolo_crud.urls), name='anular_protocolo'),
url(r'^protocoloadm/anular-protocolo', url(r'^protocoloadm/anular-protocolo',
AnularProtocoloAdmView.as_view(), name='anular_protocolo'), AnularProtocoloAdmView.as_view(), name='anular_protocolo'),
] ]

31
protocoloadm/views.py

@ -1,4 +1,5 @@
from datetime import date, datetime from datetime import date, datetime
from django import forms from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -96,19 +97,24 @@ protocolo_materia_crud = build_crud(
# [('justificativa_anulacao', 12)]], # [('justificativa_anulacao', 12)]],
# ]) # ])
def get_tipos_materia(): def get_tipos_materia():
return [('', 'Selecione')] + [(t.id, t.sigla + ' - ' + t.descricao) return [('', 'Selecione')] \
+ [(t.id, t.sigla + ' - ' + t.descricao)
for t in TipoMateriaLegislativa.objects.all()] for t in TipoMateriaLegislativa.objects.all()]
def get_range_anos(): def get_range_anos():
return [('', 'Selecione')] + [(year, year) return [('', 'Selecione')] \
for year in range(date.today().year, 1960, -1)] + [(year, year) for year in range(date.today().year, 1960, -1)]
def get_tipos_documento(): def get_tipos_documento():
return [('', 'Selecione')] + [(t.id, t.sigla + ' - ' + t.descricao) return [('', 'Selecione')] \
+ [(t.id, t.sigla + ' - ' + t.descricao)
for t in TipoDocumentoAdministrativo.objects.all()] for t in TipoDocumentoAdministrativo.objects.all()]
class ProtocoloListView(ListView): class ProtocoloListView(ListView):
template_name = 'protocoloadm/protocolo_list.html' template_name = 'protocoloadm/protocolo_list.html'
context_object_name = 'protocolos' context_object_name = 'protocolos'
@ -139,9 +145,13 @@ class ProtocoloForm(forms.Form):
attrs={'class': 'selector'})) attrs={'class': 'selector'}))
inicial = forms.DateField(label='Data Inicial', inicial = forms.DateField(label='Data Inicial',
required=False, widget=forms.TextInput(attrs={'class':'dateinput'})) required=False,
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
final = forms.DateField(label='Data Final', required=False, widget=forms.TextInput(attrs={'class':'dateinput'})) final = forms.DateField(label='Data Final', required=False,
widget=forms.TextInput(
attrs={'class': 'dateinput'}))
natureza_processo = forms.CharField( natureza_processo = forms.CharField(
label='Natureza Processo', required=False) label='Natureza Processo', required=False)
@ -161,6 +171,7 @@ class ProtocoloForm(forms.Form):
autor = forms.CharField(label='Autor', required=False) autor = forms.CharField(label='Autor', required=False)
assunto = forms.CharField(label='Assunto', required=False) assunto = forms.CharField(label='Assunto', required=False)
class ProtocoloPesquisaView(TemplateView, FormMixin): class ProtocoloPesquisaView(TemplateView, FormMixin):
template_name = 'protocoloadm/protocolo_pesquisa.html' template_name = 'protocoloadm/protocolo_pesquisa.html'
form_class = ProtocoloForm() form_class = ProtocoloForm()
@ -276,8 +287,6 @@ class AnularProtocoloAdmView(FormMixin, TemplateView):
form = AnularProcoloAdmForm(request.POST) form = AnularProcoloAdmForm(request.POST)
template_name = reverse("anular_protocolo")
if form.is_valid(): if form.is_valid():
numero = request.POST['numero_protocolo'] numero = request.POST['numero_protocolo']
@ -303,10 +312,10 @@ class AnularProtocoloAdmView(FormMixin, TemplateView):
protocolo.user_anulacao = user_anulacao protocolo.user_anulacao = user_anulacao
protocolo.ip_anulacao = ip_addr protocolo.ip_anulacao = ip_addr
protocolo.save() protocolo.save()
message = "Protocolo criado com sucesso" message = "Protocolo criado com sucesso"
return render(request,
return render(request, self.template_name, {'form': form, 'message': message}) reverse("anular_protocolo"),
{'form': form, 'message': message})
except ObjectDoesNotExist: except ObjectDoesNotExist:
errors = form._errors.setdefault( errors = form._errors.setdefault(

2
templates/protocoloadm/protocolo_pesquisa.html

@ -10,9 +10,9 @@
<table> <table>
<tr><td>Número de Protocolo</td> <tr><td>Número de Protocolo</td>
<td>Ano</td>
<td>Assunto</td> <td>Assunto</td>
<td>Tipo de Documento</td> <td>Tipo de Documento</td>
<td>Ano</td>
<td>Data</td> <td>Data</td>
</tr> </tr>
{% for p in protocolos %} {% for p in protocolos %}

Loading…
Cancel
Save