Browse Source

Change Natureza Protocolo and fix QA

pull/11/merge
Edward Ribeiro 9 years ago
parent
commit
84aa97be93
  1. 53
      protocoloadm/views.py

53
protocoloadm/views.py

@ -9,7 +9,7 @@ from django.core.urlresolvers import reverse
from django.db.models import Max from django.db.models import Max
from django.forms import ModelForm from django.forms import ModelForm
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import render from django.shortcuts import redirect, render
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -127,6 +127,13 @@ TIPOS_PROTOCOLO = [('', 'Selecione'),
('0', 'Enviado'), ('0', 'Enviado'),
('1', 'Recebido')] ('1', 'Recebido')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProtocoloForm(forms.Form): class ProtocoloForm(forms.Form):
YEARS = get_range_anos() YEARS = get_range_anos()
@ -154,8 +161,17 @@ class ProtocoloForm(forms.Form):
widget=forms.TextInput( widget=forms.TextInput(
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput'}))
natureza_processo = forms.CharField( # TODO: como pesquisar???
label='Natureza Processo', required=False) natureza_processo = forms.ChoiceField(required=False,
label='Natureza Processo',
choices=[
('0', 'Administrativo'),
('1', 'Legislativo'),
('', 'Ambos')],
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer)
)
tipo_documento = forms.ChoiceField(required=False, tipo_documento = forms.ChoiceField(required=False,
label='Tipo de Documento', label='Tipo de Documento',
choices=get_tipos_documento(), choices=get_tipos_documento(),
@ -172,6 +188,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 ProtocoloListView(FormMixin, ListView): class ProtocoloListView(FormMixin, ListView):
template_name = 'protocoloadm/protocolo_list.html' template_name = 'protocoloadm/protocolo_list.html'
context_object_name = 'protocolos' context_object_name = 'protocolos'
@ -179,9 +196,10 @@ class ProtocoloListView(FormMixin, ListView):
paginate_by = 10 paginate_by = 10
def get_queryset(self): def get_queryset(self):
kwargs = self.request.session['kwargs'] kwargs = self.request.session['kwargs']
return Protocolo.objects.filter( return Protocolo.objects.filter(
**kwargs) **kwargs)
class ProtocoloPesquisaView(FormMixin, GenericView): class ProtocoloPesquisaView(FormMixin, GenericView):
template_name = 'protocoloadm/protocolo_pesquisa.html' template_name = 'protocoloadm/protocolo_pesquisa.html'
@ -247,7 +265,6 @@ class ProtocoloPesquisaView(FormMixin, GenericView):
kwargs['assunto'] = request.POST['assunto'] kwargs['assunto'] = request.POST['assunto']
request.session['kwargs'] = kwargs request.session['kwargs'] = kwargs
from django.shortcuts import redirect
return redirect('protocolo_list') return redirect('protocolo_list')
else: else:
return self.form_invalid(form) return self.form_invalid(form)
@ -330,12 +347,6 @@ class AnularProtocoloAdmView(FormMixin, GenericView):
return self.form_invalid(form) return self.form_invalid(form)
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProtocoloDocumentForm(forms.Form): class ProtocoloDocumentForm(forms.Form):
NUMERACAO_CHOICES = [('1', 'Sequencial por Ano'), NUMERACAO_CHOICES = [('1', 'Sequencial por Ano'),
@ -815,22 +826,22 @@ class TramitacaoAdmForm(ModelForm):
input_formats=['%d/%m/%Y'], input_formats=['%d/%m/%Y'],
required=False, required=False,
widget=forms.DateInput( widget=forms.DateInput(
format='%d/%m/%Y', format='%d/%m/%Y',
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento', data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'], input_formats=['%d/%m/%Y'],
required=False, required=False,
widget=forms.DateInput( widget=forms.DateInput(
format='%d/%m/%Y', format='%d/%m/%Y',
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo', data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'], input_formats=['%d/%m/%Y'],
required=False, required=False,
widget=forms.DateInput( widget=forms.DateInput(
format='%d/%m/%Y', format='%d/%m/%Y',
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput'}))
class Meta: class Meta:
model = TramitacaoAdministrativo model = TramitacaoAdministrativo
@ -885,7 +896,7 @@ class TramitacaoAdmIncluirView(FormMixin, GenericView):
tramitacao.ultima = False tramitacao.ultima = False
tramitacao.save() tramitacao.save()
return HttpResponseRedirect( return HttpResponseRedirect(
reverse('tramitacao', kwargs={'pk': pk})) reverse('tramitacao', kwargs={'pk': pk}))
else: else:
return self.form_invalid(form) return self.form_invalid(form)
@ -913,7 +924,7 @@ class TramitacaoAdmEditView(FormMixin, GenericView):
tramitacao.ultima = False tramitacao.ultima = False
tramitacao.save() tramitacao.save()
return HttpResponseRedirect( return HttpResponseRedirect(
reverse('tramitacao', kwargs={'pk': tramitacao.documento.id})) reverse('tramitacao', kwargs={'pk': tramitacao.documento.id}))
else: else:
return self.form_invalid(form) return self.form_invalid(form)

Loading…
Cancel
Save