Browse Source

Change Natureza Protocolo and fix QA

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

31
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'
@ -183,6 +200,7 @@ class ProtocoloListView(FormMixin, ListView):
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'
form_class = ProtocoloForm() form_class = ProtocoloForm()
@ -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'),

Loading…
Cancel
Save