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

31
protocoloadm/views.py

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

2
templates/protocoloadm/protocolo_pesquisa.html

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

Loading…
Cancel
Save