Browse Source

Resolve as questoes discutidas na revisao

pull/250/head
Eduardo Calil 9 years ago
parent
commit
7b619e9e46
  1. 33
      base/models.py
  2. 4
      comissoes/forms.py
  3. 4
      comissoes/models.py
  4. 2
      comissoes/views.py
  5. 31
      materia/forms.py
  6. 10
      materia/models.py
  7. 35
      parlamentares/models.py
  8. 35
      protocoloadm/forms.py
  9. 6
      relatorios/views.py
  10. 31
      sapl/utils.py

33
base/models.py

@ -1,5 +1,6 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from sapl.utils import UF
def get_sessao_media_path(instance, subpath, filename):
@ -10,36 +11,6 @@ def get_casa_media_path(instance, filename):
return get_sessao_media_path(instance, 'Logotipo', filename)
ESTADOS = {"": "",
"AC": "ACRE",
"AL": "ALAGOAS",
"AM": "AMAZONAS",
"AP": "AMAPÁ",
"BA": "BAHIA",
"CE": "CEARÁ",
"DF": "DISTRITO FEDERAL",
"ES": "ESPíRITO SANTO",
"GO": "GOIÁS",
"MA": "MARANHÃO",
"MG": "MINAS GERAIS",
"MS": "MATO GROSSO DO SUL",
"MT": "MATO GROSSO",
"PA": "PARÁ",
"PB": "PARAÍBA",
"PE": "PERNAMBUCO",
"PI": "PIAUÍ",
"PR": "PARANÁ",
"RJ": "RIO DE JANEIRO",
"RN": "RIO GRANDE DO NORTE",
"RO": "RONDÔNIA",
"RR": "RORAIMA",
"RS": "RIO GRANDE DO SUL",
"SC": "SANTA CATARINA",
"SE": "SERGIPE",
"SP": "SÃO PAULO",
"TO": "TOCANTINS"}
class CasaLegislativa(models.Model):
# TODO ajustar todos os max_length !!!!
# cod_casa => id (pk)
@ -51,7 +22,7 @@ class CasaLegislativa(models.Model):
cep = models.CharField(max_length=100, verbose_name=_('CEP'))
municipio = models.CharField(max_length=100, verbose_name=_('Município'))
uf = models.CharField(max_length=100,
choices=[(uf, uf) for uf in ESTADOS.keys()],
choices=UF,
verbose_name=_('UF'))
telefone = models.CharField(
max_length=100, blank=True, verbose_name=_('Telefone'))

4
comissoes/forms.py

@ -138,10 +138,6 @@ class ParticipacaoCadastroForm(ModelForm):
'data_designacao': forms.DateInput(format='%d/%m/%Y'),
'data_desligamento': forms.DateInput(format='%d/%m/%Y'),
}
input_formats = {
'data_designacao': ['%d/%m/%Y'],
'data_desligamento': ['%d/%m/%Y'],
}
def __init__(self, *args, **kwargs):
self.helper = FormHelper()

4
comissoes/models.py

@ -125,9 +125,7 @@ class Participacao(models.Model): # ComposicaoComissao
parlamentar = models.ForeignKey(Parlamentar)
cargo = models.ForeignKey(CargoComissao)
titular = models.BooleanField(verbose_name=_('Titular'))
data_designacao = models.DateField(blank=True,
null=True,
verbose_name=_('Data Designação'))
data_designacao = models.DateField(verbose_name=_('Data Designação'))
data_desligamento = models.DateField(blank=True,
null=True,
verbose_name=_('Data Desligamento'))

2
comissoes/views.py

@ -137,7 +137,7 @@ class ComissaoParlamentarEditView(FormMixin, GenericView):
participacao = Participacao.objects.get(id=participacao_id)
comissao = Comissao.objects.get(id=self.kwargs['pk'])
id_parlamentar = Filiacao.objects.filter(
parlamentar__id=participacao.parlamentar.id)
parlamentar__id=participacao.parlamentar.id).order_by('data')
id_parlamentar = id_parlamentar.last().id
form = ParticipacaoCadastroForm(
initial={'parlamentar_id': id_parlamentar},

31
materia/forms.py

@ -159,9 +159,6 @@ class DocumentoAcessorioForm(ModelForm):
widgets = {
'data': forms.DateInput(attrs={'class': 'dateinput'})
}
input_formats = {
'data': ['%d/%m/%Y'],
}
def __init__(self, *args, **kwargs):
@ -203,10 +200,6 @@ class RelatoriaForm(ModelForm):
'data_destituicao_relator': forms.DateInput(attrs={
'class': 'dateinput'}),
}
input_formats = {
'data_designacao_relator': ['%d/%m/%Y'],
'data_destituicao_relator': ['%d/%m/%Y'],
}
class TramitacaoForm(ModelForm):
@ -231,17 +224,6 @@ class TramitacaoForm(ModelForm):
'data_fim_prazo': forms.DateInput(attrs={
'class': 'dateinput'}),
}
input_formats = {
'data_tramitacao': ['%d/%m/%Y'],
'data_encaminhamento': ['%d/%m/%Y'],
'data_fim_prazo': ['%d/%m/%Y'],
}
formats = {
'data_tramitacao': '%d/%m/%Y',
'data_encaminhamento': '%d/%m/%Y',
'data_fim_prazo': '%d/%m/%Y',
}
def __init__(self, *args, **kwargs):
row1 = crispy_layout_mixin.to_row(
@ -386,9 +368,6 @@ class NumeracaoForm(ModelForm):
'data_materia': forms.DateInput(attrs={'class': 'dateinput'}),
'ano_materia': forms.Select(attrs={'class': 'selector'}),
}
input_formats = {
'data_materia': ['%d/%m/%Y'],
}
def __init__(self, *args, **kwargs):
@ -453,10 +432,6 @@ class MateriaAnexadaForm(ModelForm):
'data_anexacao': forms.DateInput(attrs={'class': 'dateinput'}),
'data_desanexacao': forms.DateInput(attrs={'class': 'dateinput'}),
}
input_formats = {
'data_anexacao': ['%d/%m/%Y'],
'data_desanexacao': ['%d/%m/%Y'],
}
def __init__(self, excluir=False, *args, **kwargs):
@ -498,12 +473,6 @@ class FormularioSimplificadoForm(ModelForm):
widgets = {
'data_apresentacao': forms.DateInput(attrs={'class': 'dateinput'}),
}
input_formats = {
'data_apresentacao': ['%d/%m/%Y'],
}
formats = {
'data_apresentacao': '%d/%m/%Y'
}
def __init__(self, *args, **kwargs):

10
materia/models.py

@ -302,9 +302,7 @@ class MateriaAssunto(models.Model):
'materia': self.materia, 'assunto': self.assunto}
def get_range_anos():
return [('', 'Selecione')] \
+ [(year, year) for year in range(date.today().year, 1960, -1)]
RANGE_ANOS = [(year, year) for year in range(date.today().year, 1889, -1)]
class Numeracao(models.Model):
@ -312,11 +310,9 @@ class Numeracao(models.Model):
tipo_materia = models.ForeignKey(
TipoMateriaLegislativa, verbose_name=_('Tipo de Matéria'))
numero_materia = models.CharField(max_length=5,
verbose_name=_('Número'),
blank=True,
null=True)
verbose_name=_('Número'))
ano_materia = models.PositiveSmallIntegerField(verbose_name=_('Ano'),
choices=get_range_anos())
choices=RANGE_ANOS)
data_materia = models.DateField(
blank=True, verbose_name=_('Data'))

35
parlamentares/models.py

@ -4,7 +4,7 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _
from model_utils import Choices
from sapl.utils import YES_NO_CHOICES
from sapl.utils import YES_NO_CHOICES, UF
class Legislatura(models.Model):
@ -119,40 +119,9 @@ class Municipio(models.Model): # Localidade
('EX', 'Exterior'),
)
UF_CHOICES = (
('AC', 'Acre'),
('AL', 'Alagoas'),
('AP', 'Amapá'),
('AM', 'Amazonas'),
('BA', 'Bahia'),
('CE', 'Ceará'),
('DF', 'Distrito Federal'),
('ES', 'Espírito Santo'),
('GO', 'Goiás'),
('MA', 'Maranhão'),
('MT', 'Mato Grosso'),
('MS', 'Mato Grosso do Sul'),
('MG', 'Minas Gerais'),
('PR', 'Paraná'),
('PB', 'Paraíba'),
('PA', 'Pará'),
('PE', 'Pernambuco'),
('PI', 'Piauí'),
('RJ', 'Rio de Janeiro'),
('RN', 'Rio Grande do Norte'),
('RS', 'Rio Grande do Sul'),
('RO', 'Rondônia'),
('RR', 'Roraima'),
('SC', 'Santa Catarina'),
('SE', 'Sergipe'),
('SP', 'São Paulo'),
('TO', 'Tocantins'),
('EX', 'Exterior'),
)
nome = models.CharField(max_length=50, blank=True)
uf = models.CharField(
max_length=2, blank=True, choices=UF_CHOICES)
max_length=2, blank=True, choices=UF)
regiao = models.CharField(
max_length=2, blank=True, choices=REGIAO_CHOICES)

35
protocoloadm/forms.py

@ -400,10 +400,6 @@ class ProposicaoSimpleForm(forms.Form):
class DocumentoAcessorioAdministrativoForm(ModelForm):
data = forms.DateField(label=u'Data', input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y'))
class Meta:
model = DocumentoAcessorioAdministrativo
fields = ['tipo',
@ -413,6 +409,10 @@ class DocumentoAcessorioAdministrativoForm(ModelForm):
'arquivo',
'assunto']
widgets = {
'data': forms.DateInput(format='%d/%m/%Y')
}
def __init__(self, excluir=False, *args, **kwargs):
row1 = crispy_layout_mixin.to_row(
@ -444,27 +444,6 @@ class DocumentoAcessorioAdministrativoForm(ModelForm):
class TramitacaoAdmForm(ModelForm):
data_tramitacao = forms.DateField(label=u'Data Tramitação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = TramitacaoAdministrativo
fields = ['data_tramitacao',
@ -477,6 +456,12 @@ class TramitacaoAdmForm(ModelForm):
'documento',
]
widgets = {
'data_tramitacao': forms.DateInput(format='%d/%m/%Y'),
'data_encaminhamento': forms.DateInput(format='%d/%m/%Y'),
'data_fim_prazo': forms.DateInput(format='%d/%m/%Y'),
}
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(

6
relatorios/views.py

@ -4,7 +4,6 @@ from bs4 import BeautifulSoup
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
from base.models import ESTADOS
from base.models import CasaLegislativa
from comissoes.models import Comissao
from materia.models import (Autor, Autoria, MateriaLegislativa, Numeracao,
@ -13,6 +12,9 @@ from parlamentares.models import (CargoMesa, ComposicaoMesa, Filiacao,
Parlamentar)
from protocoloadm.models import (DocumentoAdministrativo, Protocolo,
TramitacaoAdministrativo)
from sapl.utils import UF
from sessao.models import (ExpedienteMateria, ExpedienteSessao, Orador,
OradorExpediente, OrdemDia, PresencaOrdemDia,
RegistroVotacao, SessaoPlenaria,
@ -42,7 +44,7 @@ def get_cabecalho(casa):
cabecalho = {}
cabecalho["nom_casa"] = casa.nome
# FIXME i18n
cabecalho["nom_estado"] = "Estado de " + ESTADOS[casa.uf.upper()]
cabecalho["nom_estado"] = "Estado de " + UF[casa.uf.upper()]
return cabecalho

31
sapl/utils.py

@ -64,3 +64,34 @@ def listify(function):
def f(*args, **kwargs):
return list(function(*args, **kwargs))
return f
UF = (
('AC', 'Acre'),
('AL', 'Alagoas'),
('AP', 'Amapá'),
('AM', 'Amazonas'),
('BA', 'Bahia'),
('CE', 'Ceará'),
('DF', 'Distrito Federal'),
('ES', 'Espírito Santo'),
('GO', 'Goiás'),
('MA', 'Maranhão'),
('MT', 'Mato Grosso'),
('MS', 'Mato Grosso do Sul'),
('MG', 'Minas Gerais'),
('PR', 'Paraná'),
('PB', 'Paraíba'),
('PA', 'Pará'),
('PE', 'Pernambuco'),
('PI', 'Piauí'),
('RJ', 'Rio de Janeiro'),
('RN', 'Rio Grande do Norte'),
('RS', 'Rio Grande do Sul'),
('RO', 'Rondônia'),
('RR', 'Roraima'),
('SC', 'Santa Catarina'),
('SE', 'Sergipe'),
('SP', 'São Paulo'),
('TO', 'Tocantins'),
('EX', 'Exterior'),
)

Loading…
Cancel
Save