Browse Source

Fix autor input in search forms

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
1ecbd53b88
  1. 2
      materia/models.py
  2. 7
      materia/views.py
  3. 1
      parlamentares/urls.py
  4. 38
      protocoloadm/views.py
  5. 1
      sapl/crud.py

2
materia/models.py

@ -205,7 +205,7 @@ class Autor(models.Model):
def __str__(self):
if str(self.tipo) == 'Parlamentar':
return str(self.parlamentar)
return self.parlamentar.nome_parlamentar
elif str(self.tipo) == 'Comissao':
return str(self.comissao)
elif str(self.tipo) == 'Partido':

7
materia/views.py

@ -1,8 +1,6 @@
from datetime import date
from re import sub
import sapl
from comissoes.models import Comissao, Composicao
from crispy_forms.helper import FormHelper
from crispy_forms.layout import (HTML, ButtonHolder, Column, Fieldset, Layout,
Submit)
@ -15,9 +13,12 @@ from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView
from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
from comissoes.models import Comissao, Composicao
from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica
from sapl.crud import build_crud
from vanilla import GenericView
from .models import (Anexada, Autor, Autoria, DespachoInicial,
DocumentoAcessorio, MateriaLegislativa, Numeracao, Orgao,

1
parlamentares/urls.py

@ -1,4 +1,5 @@
from django.conf.urls import include, url
from parlamentares.views import (ParlamentaresCadastroView,
ParlamentaresEditarView, ParlamentaresView,
cargo_mesa_crud, coligacao_crud,

38
protocoloadm/views.py

@ -1,7 +1,6 @@
from datetime import date, datetime
from re import sub
import sapl
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Field, Fieldset, Layout, Submit
from django import forms
@ -17,9 +16,11 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, ListView
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud
from vanilla import GenericView
from .models import (Autor, DocumentoAcessorioAdministrativo,
DocumentoAdministrativo, Protocolo,
@ -134,7 +135,12 @@ class HorizontalRadioRenderer(forms.RadioSelect.renderer):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProtocoloForm(ModelForm):
def get_autores():
return [('', 'Selecione')] \
+ [(a.id, str(a)) for a in Autor.objects.all().order_by('tipo')]
class ProtocoloForm(forms.Form):
YEARS = get_range_anos()
@ -184,23 +190,13 @@ class ProtocoloForm(ModelForm):
widget=forms.Select(
attrs={'class': 'selector'}))
autor = forms.CharField(label='Autor', required=False)
autor = forms.ChoiceField(required=False,
label='Autor',
choices=get_autores(),
widget=forms.Select(
attrs={'class': 'selector'}))
assunto = forms.CharField(label='Assunto', required=False)
class Meta:
model = Protocolo
fields = ['assunto',
'autor',
'interessado',
'tipo_materia',
'tipo_documento',
'natureza_processo',
'final',
'inicial',
'ano',
'numero_protocolo',
'tipo_protocolo']
def __init__(self, *args, **kwargs):
row1 = sapl.layout.to_row(
@ -541,7 +537,11 @@ class ProtocoloMateriaForm(forms.Form):
num_paginas = forms.CharField(label='Núm. Páginas', required=True)
ementa = forms.CharField(
widget=forms.Textarea, label='Ementa', required=True)
autor = forms.CharField(label='Autor', required=True)
autor = forms.ChoiceField(required=False,
label='Autor',
choices=get_autores(),
widget=forms.Select(
attrs={'class': 'selector'}))
observacao = forms.CharField(required=True,
widget=forms.Textarea,
label='Observação')

1
sapl/crud.py

@ -1,6 +1,5 @@
from braces.views import FormMessagesMixin
from crispy_forms.helper import FormHelper
from datetime import datetime
from django import forms
from django.conf.urls import url
from django.core.urlresolvers import reverse, reverse_lazy

Loading…
Cancel
Save